hasura-backend-plus icon indicating copy to clipboard operation
hasura-backend-plus copied to clipboard

Upload file with metadata to later download file with "orginalname"

Open mstephano opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe. Currently, it seams that passing metadata to storage.put() is not currently implemented in nhost-js-sdk: https://github.com/nhost/nhost-js-sdk/blob/9d3d34c29e4c078abb591fcdc96eee4728c2e5f6/src/Storage.ts#L54

Describe the solution you'd like I would like to be able to save the "originalname" of the file as metadata so it can be downloaded using that originalname like the example from Hasura: https://hasura.io/blog/building-file-upload-downloads-for-your-hasura-app/.

Currently the header "Content-Disposition" is missing "filename" like in the Hasura example in order to retrieve the file using the "originalname": https://github.com/nhost/hasura-backend-plus/blob/21093598aaadf65088dfcdc052c01f0a19f98d3e/src/routes/storage/get.ts#L163

Additional context This feature would allow us to save every file as unique using uuidv4() but still retrieve as the filename that was originally uploaded.

mstephano avatar Sep 03 '21 18:09 mstephano

For those interested, my commit works as I described: https://github.com/mstephano/hasura-backend-plus/commit/5ea8eab6518caf95876b67548a160312000a0a69

mstephano avatar Sep 03 '21 18:09 mstephano

For information, I forgot to mention that I am using the create-react-app typescript example as web app: https://github.com/nhost/nhost-react-typescript-example-app

Note: I know the project as been archived but I needed an example using create-react-app with typescript in order to try nhost.

mstephano avatar Sep 03 '21 18:09 mstephano