Skip to content

Commit

Permalink
fix: use admin secret to update metadata when uploading files (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop authored Apr 11, 2022
1 parent e5857bc commit e1ea387
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions controller/upload_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,18 @@ func (ctrl *Controller) upload(

etag, contentType, err := ctrl.uploadSingleFile(file, file.ID)
if err != nil {
_, _ = ctrl.metadataStorage.DeleteFileByID(ctx, file.ID, request.headers)
_, _ = ctrl.metadataStorage.DeleteFileByID(
ctx,
file.ID,
http.Header{"x-hasura-admin-secret": []string{ctrl.hasuraAdminSecret}},
)
return filesMetadata, InternalServerError(fmt.Errorf("problem processing file %s: %w", file.Name, err))
}

metadata, apiErr := ctrl.metadataStorage.PopulateMetadata(
ctx,
file.ID, file.Name, file.header.Size, bucket.ID, etag, true, contentType,
request.headers,
http.Header{"x-hasura-admin-secret": []string{ctrl.hasuraAdminSecret}},
)
if apiErr != nil {
return filesMetadata, apiErr.ExtendError(fmt.Sprintf("problem populating file metadata for file %s", file.Name))
Expand Down

0 comments on commit e1ea387

Please sign in to comment.