support thumbnails in spaces

This commit is contained in:
David Christofas
2022-02-23 15:52:02 +01:00
parent d92dc8951a
commit caeb2b684d
5 changed files with 99 additions and 19 deletions
+16 -3
View File
@@ -217,11 +217,24 @@ func (g Thumbnail) handleWebdavSource(ctx context.Context, req *thumbnailssvc.Ge
func (g Thumbnail) stat(path, auth string) (*provider.StatResponse, error) {
ctx := metadata.AppendToOutgoingContext(context.Background(), revactx.TokenHeader, auth)
req := &provider.StatRequest{
Ref: &provider.Reference{
var ref *provider.Reference
if strings.Contains(path, "!") {
parts := strings.Split(path, "!")
spaceID, path := parts[0], parts[1]
ref = &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: spaceID,
OpaqueId: spaceID,
},
Path: path,
},
}
} else {
ref = &provider.Reference{
Path: path,
}
}
req := &provider.StatRequest{Ref: ref}
rsp, err := g.cs3Client.Stat(ctx, req)
if err != nil {
g.logger.Error().Err(err).Str("path", path).Msg("could not stat file")
+18 -5
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
@@ -42,12 +43,24 @@ func (s CS3) Get(ctx context.Context, path string) (io.ReadCloser, error) {
if !ok {
return nil, errors.New("cs3source: authorization missing")
}
ctx = metadata.AppendToOutgoingContext(context.Background(), revactx.TokenHeader, auth)
rsp, err := s.client.InitiateFileDownload(ctx, &provider.InitiateFileDownloadRequest{
Ref: &provider.Reference{
var ref *provider.Reference
if strings.Contains(path, "!") {
parts := strings.Split(path, "!")
spaceID, path := parts[0], parts[1]
ref = &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: spaceID,
OpaqueId: spaceID,
},
Path: path,
},
})
}
} else {
ref = &provider.Reference{
Path: path,
}
}
ctx = metadata.AppendToOutgoingContext(context.Background(), revactx.TokenHeader, auth)
rsp, err := s.client.InitiateFileDownload(ctx, &provider.InitiateFileDownloadRequest{Ref: ref})
if err != nil {
return nil, err