Send additional data to Companion to create a directory in S3
See original GitHub issueHi, I’m trying to upload files to S3 with a standalone server, everything is working file, just one customization needed.
I want the files to be uploaded in a directory in a bucket.
So if I send username/file-name.jpg as the file Key then the S3 will create a directory-like structure in the bucket, so every time a user uploads a file, it’ll be uploaded in his/her folder.
I’m using this code to send the files to the server.
.use(Uppy.AwsS3, { companionUrl: 'https://uploader.domain.com' })
I want to send additional data like:
.use(Uppy.AwsS3, { companionUrl: 'https://uploader.domain.com', userName: 'abc123' })
then access this userName in the Uppy.js file and append it to the filename like:
providerOptions: { s3: { endpoint: 'https://{service}.{region}.amazonaws.com', conditions: [], getKey: (req, filename) => userName +'/'+ filename } }
Thanks in advance.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (1 by maintainers)
The “best” way currently is using headers.
On the client side, you can do:
On the server side, make sure you allow the header:
You can access it in the
getKey
option:In the future we will hopefully support accessing Uppy metadata in
getKey()
directly to make this less annoying!@acrolink Kudos. It worked like a charm. Thank you very much 😃