|
|
|
@ -65,7 +65,8 @@ type Object interface {
|
|
|
|
|
// ObjectStorage represents an object storage to handle a bucket and files
|
|
|
|
|
type ObjectStorage interface {
|
|
|
|
|
Open(path string) (Object, error)
|
|
|
|
|
Save(path string, r io.Reader) (int64, error)
|
|
|
|
|
// Save store a object, if size is unknown set -1
|
|
|
|
|
Save(path string, r io.Reader, size int64) (int64, error)
|
|
|
|
|
Stat(path string) (os.FileInfo, error)
|
|
|
|
|
Delete(path string) error
|
|
|
|
|
URL(path, name string) (*url.URL, error)
|
|
|
|
@ -80,7 +81,13 @@ func Copy(dstStorage ObjectStorage, dstPath string, srcStorage ObjectStorage, sr
|
|
|
|
|
}
|
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
|
|
return dstStorage.Save(dstPath, f)
|
|
|
|
|
size := int64(-1)
|
|
|
|
|
fsinfo, err := f.Stat()
|
|
|
|
|
if err == nil {
|
|
|
|
|
size = fsinfo.Size()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dstStorage.Save(dstPath, f, size)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SaveFrom saves data to the ObjectStorage with path p from the callback
|
|
|
|
@ -94,7 +101,7 @@ func SaveFrom(objStorage ObjectStorage, p string, callback func(w io.Writer) err
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
_, err := objStorage.Save(p, pr)
|
|
|
|
|
_, err := objStorage.Save(p, pr, -1)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|