diff --git a/packages/@uppy/aws-s3/src/index.ts b/packages/@uppy/aws-s3/src/index.ts index 7f0dbd511..205decbd7 100644 --- a/packages/@uppy/aws-s3/src/index.ts +++ b/packages/@uppy/aws-s3/src/index.ts @@ -334,7 +334,15 @@ export default class AwsS3 extends BasePlugin< } #generateKey(file: UppyFile): string { - return this.opts.generateObjectKey?.(file) ?? file.name + // in companion mode, no need to run the generateObjectKey function even if it's passed by the user, + // because the key is generated on the server side and we need to remove the option to pass generateObjectKey in companion mode. + if ('companionEndpoint' in this.opts) { + return file.name + } + return ( + this.opts.generateObjectKey?.(file) ?? + `${crypto.randomUUID()}-${file.name}` + ) } // --------------------------------------------------------------------------