Skip to content

Commit

Permalink
feat: add folder id to dav mkcol responses
Browse files Browse the repository at this point in the history
Adds the `OC-FileId` header to dav `mkcol` responses, containing the id of the newly created folder.

This is necessary for clients that work with ids and want to fetch a folder immediately after creating.
  • Loading branch information
Jannik Stehle committed Jul 17, 2024
1 parent 11ee452 commit 503b208
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/add-folder-id-to-mkcol-response.md
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions internal/http/services/owncloud/ocdav/mkcol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 503b208

Please sign in to comment.