mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-09 05:26:24 +09:00
encode asset name only when writing to s3 and when building the path after reading from the db, but keep it as-is in the db
This commit is contained in:
1 parent
21fdd770fa
commit
f7d5f3b3fe
2 files changed
+4
-4
No files matched your search
@@ -68,7 +68,7 @@ const uploadHandler = async ({
|
||||
throw new Error(`Asset cannot be bigger than ${maxSize}MB`);
|
||||
}
|
||||
|
||||
const uniqueFilename = encodeURIComponent(getUniqueFilename(file.filename));
|
||||
const uniqueFilename = getUniqueFilename(file.filename);
|
||||
|
||||
const s3Envs = S3EnvVariables.parse(process.env);
|
||||
|
||||
@@ -78,7 +78,7 @@ const uploadHandler = async ({
|
||||
const params: PutObjectCommandInput = {
|
||||
...ACL,
|
||||
Bucket: s3Envs.S3_BUCKET,
|
||||
Key: uniqueFilename,
|
||||
Key: encodeURIComponent(uniqueFilename),
|
||||
Body: buffer,
|
||||
ContentType: file.contentType,
|
||||
Metadata: {
|
||||
|
||||
@@ -14,12 +14,12 @@ export const getAssetPath = (asset: DbAsset) => {
|
||||
if (asset.location === Location.REMOTE && s3Envs.success) {
|
||||
if (s3Envs.data.ASSET_CDN_URL) {
|
||||
const cndUrl = new URL(s3Envs.data.ASSET_CDN_URL);
|
||||
cndUrl.pathname = asset.name;
|
||||
cndUrl.pathname = encodeURIComponent(asset.name);
|
||||
return cndUrl.toString();
|
||||
}
|
||||
const s3Url = new URL(s3Envs.data.S3_ENDPOINT);
|
||||
s3Url.hostname = `${s3Envs.data.S3_BUCKET}.${s3Url.hostname}`;
|
||||
s3Url.pathname = asset.name;
|
||||
s3Url.pathname = encodeURIComponent(asset.name);
|
||||
return s3Url.toString();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user