@@ -17,7 +17,7 @@ type FileSystem interface {
1717 Open (ctx context.Context , name string ) (io.ReadCloser , error )
1818 Stat (ctx context.Context , name string ) (* FileInfo , error )
1919 ReadDir (ctx context.Context , name string , recursive bool ) ([]FileInfo , error )
20- Create (ctx context.Context , name string , body io.ReadCloser ) error
20+ Create (ctx context.Context , name string , body io.ReadCloser , size int64 ) error
2121 RemoveAll (ctx context.Context , name string ) error
2222 Mkdir (ctx context.Context , name string ) error
2323 Copy (ctx context.Context , name , dest string , options * CopyOptions ) (created bool , err error )
@@ -45,7 +45,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
4545// NewHTTPError creates a new error that is associated with an HTTP status code
4646// and optionally an error that lead to it. Backends can use this functions to
4747// return errors that convey some semantics (e.g. 404 not found, 403 access
48- // denied, etc) while also providing an (optional) arbitrary error context
48+ // denied, etc. ) while also providing an (optional) arbitrary error context
4949// (intended for humans).
5050func NewHTTPError (statusCode int , cause error ) error {
5151 return & internal.HTTPError {Code : statusCode , Err : cause }
@@ -194,7 +194,12 @@ func (b *backend) PropPatch(r *http.Request, update *internal.PropertyUpdate) (*
194194}
195195
196196func (b * backend ) Put (w http.ResponseWriter , r * http.Request ) error {
197- err := b .FileSystem .Create (r .Context (), r .URL .Path , r .Body )
197+ contentLength := r .Header .Get ("Content-Length" )
198+ size , err := strconv .ParseInt (contentLength , 10 , 64 )
199+ if err != nil {
200+ return err
201+ }
202+ err = b .FileSystem .Create (r .Context (), r .URL .Path , r .Body , size )
198203 if err != nil {
199204 return err
200205 }
0 commit comments