Skip to content

Commit 2f5eb05

Browse files
author
Bob Strahan
committed
fix: ensure proper URL encoding of S3 object keys in presigned URLs
1 parent a4707ff commit 2f5eb05

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ui/src/components/common/generate-s3-presigned-url.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ const generateS3PresignedUrl = async (url, credentials) => {
6363
// Extract region from env
6464
const region = process.env.REACT_APP_AWS_REGION;
6565

66-
// Construct the canonical S3 URL
67-
const newUrl = `https://${bucketName}.s3.${region}.amazonaws.com/${key}`;
66+
// Construct the canonical S3 URL with properly encoded key
67+
const encodedKey = key
68+
.split('/')
69+
.map((segment) => encodeURIComponent(segment))
70+
.join('/');
71+
const newUrl = `https://${bucketName}.s3.${region}.amazonaws.com/${encodedKey}`;
6872

6973
// Parse the URL for the presigner
7074
const s3ObjectUrl = parseUrl(newUrl);

0 commit comments

Comments
 (0)