diff --git a/changelog/unreleased/add-folder-id-to-mkcol-response.md b/changelog/unreleased/add-folder-id-to-mkcol-response.md new file mode 100644 index 0000000000..1c56265f51 --- /dev/null +++ b/changelog/unreleased/add-folder-id-to-mkcol-response.md @@ -0,0 +1,6 @@ +Enhancement: Folder id in mkcol dav responses + +`mkcol` dav responses now have the `OC-FileId` header containing the id of the created folder. + +https://github.com/cs3org/reva/pull/4767 +https://github.com/owncloud/ocis/issues/9618 diff --git a/internal/http/services/owncloud/ocdav/mkcol.go b/internal/http/services/owncloud/ocdav/mkcol.go index 1a1f57e75b..0f0c6241c8 100644 --- a/internal/http/services/owncloud/ocdav/mkcol.go +++ b/internal/http/services/owncloud/ocdav/mkcol.go @@ -27,10 +27,12 @@ import ( rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/spacelookup" "github.com/cs3org/reva/v2/pkg/appctx" "github.com/cs3org/reva/v2/pkg/errtypes" rstatus "github.com/cs3org/reva/v2/pkg/rgrpc/status" + "github.com/cs3org/reva/v2/pkg/storagespace" "github.com/cs3org/reva/v2/pkg/utils" "github.com/rs/zerolog" ) @@ -123,6 +125,14 @@ func (s *svc) handleMkcol(ctx context.Context, w http.ResponseWriter, r *http.Re case err != nil: return http.StatusInternalServerError, err case res.Status.Code == rpc.Code_CODE_OK: + sReq := &provider.StatRequest{ + Ref: childRef, + } + sRes, err := client.Stat(ctx, sReq) + if err != nil { + return http.StatusInternalServerError, err + } + w.Header().Set(net.HeaderOCFileID, storagespace.FormatResourceID(sRes.GetInfo().GetId())) w.WriteHeader(http.StatusCreated) return 0, nil case res.Status.Code == rpc.Code_CODE_NOT_FOUND: