Update the upload length in FileInfo when it's sent
@@ -456,6 +456,17 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request
return
}
+ if info.SizeIsDeferred && r.Header.Get("Upload-Length") != "" {
+ uploadLength, err := strconv.ParseInt(r.Header.Get("Upload-Length"), 10, 64)
+ if err != nil || uploadLength < 0 {
+ handler.sendError(w, r, ErrInvalidOffset)
+ return
+ }
+
+ info.Size = uploadLength
+ info.SizeIsDeferred = false
+ }
+
if err := handler.writeChunk(id, info, w, r); err != nil {
handler.sendError(w, r, err)
return
