diff --git a/changelog/unreleased/fix-creating-documents.md b/changelog/unreleased/fix-creating-documents.md new file mode 100644 index 0000000000..4206541b40 --- /dev/null +++ b/changelog/unreleased/fix-creating-documents.md @@ -0,0 +1,5 @@ +Bugfix: Fix creating documents in the approvider + +We fixed a problem with the approvider where an error was reported to the user even though the file was created properly. + +https://github.com/cs3org/reva/pull/4479 diff --git a/internal/http/services/appprovider/appprovider.go b/internal/http/services/appprovider/appprovider.go index c121657885..2181e98b95 100644 --- a/internal/http/services/appprovider/appprovider.go +++ b/internal/http/services/appprovider/appprovider.go @@ -276,9 +276,8 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { return } defer httpRes.Body.Close() - if httpRes.StatusCode == http.StatusForbidden { + if httpRes.StatusCode == http.StatusBadRequest { // the file upload was already finished since it is a zero byte file - // TODO: why do we get a 401 then!? } else if httpRes.StatusCode != http.StatusOK { writeError(w, r, appErrorServerError, "failed to create the file", nil) return diff --git a/pkg/rhttp/datatx/manager/simple/simple.go b/pkg/rhttp/datatx/manager/simple/simple.go index a89ce71ecd..6699c9f77a 100644 --- a/pkg/rhttp/datatx/manager/simple/simple.go +++ b/pkg/rhttp/datatx/manager/simple/simple.go @@ -93,6 +93,13 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) { defer func() { metrics.UploadsActive.Sub(1) }() + + if r.ContentLength == 0 { + sublog.Info().Msg("received invalid 0-byte PUT request") + w.WriteHeader(http.StatusBadRequest) + return + } + fn := r.URL.Path defer r.Body.Close()