Skip to content

Commit

Permalink
Indicate in EOS containers that TUS is not supported (#1415)
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 authored Jan 21, 2021
1 parent a7bf52b commit 7fe671a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
8 changes: 8 additions & 0 deletions changelog/unreleased/eos-disable-tus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enhancement: Indicate in EOS containers that TUS is not supported

The OCDAV propfind response previously hardcoded the TUS headers due to which
clients such as phoenix used the TUS protocol for uploads, which EOS doesn't
support. Now we pass this property as an opaque entry in the containers
metadata.

https://github.com/cs3org/reva/pull/1415
15 changes: 11 additions & 4 deletions internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,19 @@ func (s *svc) handlePropfind(w http.ResponseWriter, r *http.Request, ns string)
}
w.Header().Set("DAV", "1, 3, extended-mkcol")
w.Header().Set("Content-Type", "application/xml; charset=utf-8")

var disableTus bool
// let clients know this collection supports tus.io POST requests to start uploads
if info.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER {
w.Header().Add("Access-Control-Expose-Headers", "Tus-Resumable, Tus-Version, Tus-Extension")
w.Header().Set("Tus-Resumable", "1.0.0")
w.Header().Set("Tus-Version", "1.0.0")
w.Header().Set("Tus-Extension", "creation,creation-with-upload")
if info.Opaque != nil {
_, disableTus = info.Opaque.Map["disable_tus"]
}
if !disableTus {
w.Header().Add("Access-Control-Expose-Headers", "Tus-Resumable, Tus-Version, Tus-Extension")
w.Header().Set("Tus-Resumable", "1.0.0")
w.Header().Set("Tus-Version", "1.0.0")
w.Header().Set("Tus-Extension", "creation,creation-with-upload")
}
}
w.WriteHeader(http.StatusMultiStatus)
if _, err := w.Write([]byte(propRes)); err != nil {
Expand Down
7 changes: 7 additions & 0 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,13 @@ func (fs *eosfs) convert(ctx context.Context, eosFileInfo *eosclient.FileInfo) (
},
}

if eosFileInfo.IsDir {
info.Opaque.Map["disable_tus"] = &types.OpaqueEntry{
Decoder: "plain",
Value: []byte("true"),
}
}

info.Type = getResourceType(eosFileInfo.IsDir)
return info, nil
}
Expand Down

0 comments on commit 7fe671a

Please sign in to comment.