@@ -17,7 +17,7 @@ type FileSystem interface {
17
17
Open (ctx context.Context , name string ) (io.ReadCloser , error )
18
18
Stat (ctx context.Context , name string ) (* FileInfo , error )
19
19
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
21
21
RemoveAll (ctx context.Context , name string ) error
22
22
Mkdir (ctx context.Context , name string ) error
23
23
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) {
45
45
// NewHTTPError creates a new error that is associated with an HTTP status code
46
46
// and optionally an error that lead to it. Backends can use this functions to
47
47
// 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
49
49
// (intended for humans).
50
50
func NewHTTPError (statusCode int , cause error ) error {
51
51
return & internal.HTTPError {Code : statusCode , Err : cause }
@@ -194,7 +194,12 @@ func (b *backend) PropPatch(r *http.Request, update *internal.PropertyUpdate) (*
194
194
}
195
195
196
196
func (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 )
198
203
if err != nil {
199
204
return err
200
205
}
0 commit comments