coalesce options bucket and getKey (#5169)

* coalesce options `bucket` and `getKey`

this is a breaking change!
also:
- remove `req` because it's an internal, unstable api that might change any time and should not be used directly
- use an params object for getKey/bucket functions instead of positional arguments, to make it more clean, and easier to add more data in the future
- add metadata to `bucket` whenever we are aware of it

* fix lint

* Apply suggestions from code review

Co-authored-by: Antoine du Hamel <antoine@transloadit.com>

* add back `Request` object

also add filename to `bucket` for consistency

* add migration steps

* fix lint

* Update docs/guides/migration-guides.md

Co-authored-by: Antoine du Hamel <antoine@transloadit.com>

---------

Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
This commit is contained in:
Mikael Finstad 2024-06-13 23:32:38 +02:00 committed by GitHub
parent 087d8f07f0
commit 151da8bdfe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 71 additions and 47 deletions

View file

@ -29,7 +29,7 @@ const options = {
},
},
s3: {
getKey: (req, filename) => `${crypto.randomUUID()}-${filename}`,
getKey: ({ filename }) => `${crypto.randomUUID()}-${filename}`,
key: process.env.COMPANION_AWS_KEY,
secret: process.env.COMPANION_AWS_SECRET,
bucket: process.env.COMPANION_AWS_BUCKET,

View file

@ -37,7 +37,7 @@ const { app: companionApp } = companion.app({
s3: {
// This is the crucial part; set an endpoint template for the service you want to use.
endpoint: 'https://{region}.digitaloceanspaces.com',
getKey: (req, filename) => `${crypto.randomUUID()}-${filename}`,
getKey: ({ filename }) => `${crypto.randomUUID()}-${filename}`,
key: process.env.COMPANION_AWS_KEY,
secret: process.env.COMPANION_AWS_SECRET,