Skip to content

Commit 2c922b8

Browse files
committed
fix: Use the unencoded file name instead of the encoded one to submit s3 urls for presigning
(s3 will encode the filename when it performs GetObjectCommand, but filename is already encoded and will be double encoded!)
1 parent e634835 commit 2c922b8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,12 @@ class S3Adapter {
228228
}
229229

230230
const fileKey = `${this._bucketPrefix}${fileName}`;
231+
// For presigned URLs, use the original unencoded filename to prevent double encoding
232+
const presignedFileKey = `${this._bucketPrefix}${filename}`;
231233

232234
let presignedUrl = '';
233235
if (this._presignedUrl) {
234-
const params = { Bucket: this._bucket, Key: fileKey };
236+
const params = { Bucket: this._bucket, Key: presignedFileKey };
235237
const options = this._presignedUrlExpires ? { expiresIn: this._presignedUrlExpires } : {};
236238

237239
const command = new GetObjectCommand(params);

0 commit comments

Comments
 (0)