Skip to content

Commit

Permalink
@uppy/companion: fix default getKey for non-standalone too (transload…
Browse files Browse the repository at this point in the history
…it#3945)

And update docs.
  • Loading branch information
mifi committed Aug 4, 2022
1 parent 1133f79 commit f39a683
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/config/companion.js
Expand Up @@ -2,6 +2,7 @@ const ms = require('ms')
const fs = require('node:fs')
const { isURL } = require('validator')
const logger = require('../server/logger')
const { defaultGetKey } = require('../server/helpers/utils')

const defaultOptions = {
server: {
Expand All @@ -13,7 +14,7 @@ const defaultOptions = {
endpoint: 'https://{service}.{region}.amazonaws.com',
conditions: [],
useAccelerateEndpoint: false,
getKey: (req, filename) => filename,
getKey: defaultGetKey,
expires: ms('5 minutes') / 1000,
},
allowLocalUrls: false,
Expand Down
2 changes: 2 additions & 0 deletions src/server/helpers/utils.js
Expand Up @@ -164,3 +164,5 @@ module.exports.requestStream = async (req, convertResponseToError) => {

return { stream: resp }
}

module.exports.defaultGetKey = (req, filename) => `${crypto.randomUUID()}-${filename}`
2 changes: 1 addition & 1 deletion src/standalone/helper.js
Expand Up @@ -72,7 +72,7 @@ const getConfigFromEnv = () => {
},
s3: {
key: process.env.COMPANION_AWS_KEY,
getKey: (req, filename) => `${crypto.randomUUID()}-${filename}`,
getKey: utils.defaultGetKey,
secret: getSecret('COMPANION_AWS_SECRET'),
bucket: process.env.COMPANION_AWS_BUCKET,
endpoint: process.env.COMPANION_AWS_ENDPOINT,
Expand Down

0 comments on commit f39a683

Please sign in to comment.