feat: updated presigned url response to include the file size so client can decide if it can be displayed or not

This commit is contained in:
Andrey Melnikov
2021-07-30 14:01:38 -07:00
parent d226028b33
commit 8e6ef8d3eb
13 changed files with 463 additions and 815 deletions

View File

@@ -96,7 +96,8 @@ func (s *FileServer) ListFiles(ctx context.Context, req *api.ListFilesRequest) (
}, nil
}
func (s *FileServer) GetObjectPresignedUrl(ctx context.Context, req *api.GetObjectPresignedUrlRequest) (*api.GetPresignedUrlResponse, error) {
// GetObjectDownloadPresignedUrl returns a downloadable url for a given object
func (s *FileServer) GetObjectDownloadPresignedUrl(ctx context.Context, req *api.GetObjectPresignedUrlRequest) (*api.GetPresignedUrlResponse, error) {
// TODO resource is workflows for now, should it be something else?
client := getClient(ctx)
allowed, err := auth.IsAuthorized(client, req.Namespace, "list", "argoproj.io", "workflows", "")
@@ -104,12 +105,13 @@ func (s *FileServer) GetObjectPresignedUrl(ctx context.Context, req *api.GetObje
return nil, err
}
signedURL, err := client.GetObjectPresignedURL(req.Namespace, req.Key)
downloadObj, err := client.GetObjectPresignedURL(req.Namespace, req.Key)
if err != nil {
return nil, err
}
return &api.GetPresignedUrlResponse{
Url: signedURL,
Url: downloadObj.URL,
Size: downloadObj.Size,
}, nil
}