@@ -65,7 +65,8 @@ type Object interface {
6565// ObjectStorage represents an object storage to handle a bucket and files
6666type ObjectStorage interface {
6767 Open (path string ) (Object , error )
68- Save (path string , r io.Reader ) (int64 , error )
68+ // Save store a object, if size is unknown set -1
69+ Save (path string , r io.Reader , size int64 ) (int64 , error )
6970 Stat (path string ) (os.FileInfo , error )
7071 Delete (path string ) error
7172 URL (path , name string ) (* url.URL , error )
@@ -80,7 +81,13 @@ func Copy(dstStorage ObjectStorage, dstPath string, srcStorage ObjectStorage, sr
8081 }
8182 defer f .Close ()
8283
83- return dstStorage .Save (dstPath , f )
84+ size := int64 (- 1 )
85+ fsinfo , err := f .Stat ()
86+ if err == nil {
87+ size = fsinfo .Size ()
88+ }
89+
90+ return dstStorage .Save (dstPath , f , size )
8491}
8592
8693// 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
94101 }
95102 }()
96103
97- _ , err := objStorage .Save (p , pr )
104+ _ , err := objStorage .Save (p , pr , - 1 )
98105 return err
99106}
100107
0 commit comments