Skip to content

Commit 503b208

Browse files
author
Jannik Stehle
committed
feat: add folder id to dav mkcol responses
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.
1 parent 11ee452 commit 503b208

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Enhancement: Folder id in mkcol dav responses
2+
3+
`mkcol` dav responses now have the `OC-FileId` header containing the id of the created folder.
4+
5+
https://github.com/cs3org/reva/pull/4767
6+
https://github.com/owncloud/ocis/issues/9618

internal/http/services/owncloud/ocdav/mkcol.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ import (
2727

2828
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
2929
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
30+
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net"
3031
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/spacelookup"
3132
"github.com/cs3org/reva/v2/pkg/appctx"
3233
"github.com/cs3org/reva/v2/pkg/errtypes"
3334
rstatus "github.com/cs3org/reva/v2/pkg/rgrpc/status"
35+
"github.com/cs3org/reva/v2/pkg/storagespace"
3436
"github.com/cs3org/reva/v2/pkg/utils"
3537
"github.com/rs/zerolog"
3638
)
@@ -123,6 +125,14 @@ func (s *svc) handleMkcol(ctx context.Context, w http.ResponseWriter, r *http.Re
123125
case err != nil:
124126
return http.StatusInternalServerError, err
125127
case res.Status.Code == rpc.Code_CODE_OK:
128+
sReq := &provider.StatRequest{
129+
Ref: childRef,
130+
}
131+
sRes, err := client.Stat(ctx, sReq)
132+
if err != nil {
133+
return http.StatusInternalServerError, err
134+
}
135+
w.Header().Set(net.HeaderOCFileID, storagespace.FormatResourceID(sRes.GetInfo().GetId()))
126136
w.WriteHeader(http.StatusCreated)
127137
return 0, nil
128138
case res.Status.Code == rpc.Code_CODE_NOT_FOUND:

0 commit comments

Comments
 (0)