Can presign endpoint response with a storage key?

Hi
I’m using presign endpoint for direct s3 upload.
For creating endpoint I must set storage key.
mount Shrine.presign_endpoint(:presign_cache), at: '/s3/params', as: :s3_params
But it will not be present in the response of presign endpoint.
Because of that, I have to store it somewhere on the frontend also.

Did I miss something and there is a way to add storage key to response?
Thanks.

Yeah, it would be good if it was in the response, but the last time I checked Uppy’s aws-s3 plugin doesn’t allow you to retrieve additional response data (though that could have changed).

Would you have use of this outside Uppy usage?

I would ideally like to include the file ID and metadata as well, to reduce the logic needed on the frontend, as currently there is some coupling to the backend.

I’m not using uppy, i’ve implemented upload on my own.

Ok, in this case it would be worthwhile adding the file data into the presign response. I added it to my TODO list for the next version, in the meanwhile I believe you can achieve with the following configuration:

Shrine.plugin :presign_endpoint, presign: -> (id, options, request) do
  data = Shrine.storages[:cache].presign(id, options)

  data[:fields] ||= {}
  data[:headers] ||= {}
  data[:file] = {
    id: id,
    storage: :cache,
  }
  
  data
end

That should give you "file": { "id": "abc123...", "storage": "cache" } in the respnose.