Skip to content

Commit 9b9ba34

Browse files
authored
fix: Fix svg upload (#5545)
## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent cf1f929 commit 9b9ba34

File tree

1 file changed

+5
-1
lines changed
  • packages/asset-uploader/src/clients/s3

1 file changed

+5
-1
lines changed

packages/asset-uploader/src/clients/s3/upload.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { SignatureV4 } from "@smithy/signature-v4";
33
import { type AssetData, getAssetData } from "../../utils/get-asset-data";
44
import { createSizeLimiter } from "../../utils/size-limiter";
55
import { extendedEncodeURIComponent } from "../../utils/sanitize-s3-key";
6+
import { getMimeTypeByFilename } from "@webstudio-is/sdk";
67

78
export const uploadToS3 = async ({
89
signer,
@@ -40,14 +41,17 @@ export const uploadToS3 = async ({
4041
endpoint
4142
);
4243

44+
// Use proper MIME type based on file extension instead of generic type category
45+
const contentType = getMimeTypeByFilename(name);
46+
4347
const s3Request = await signer.sign({
4448
method: "PUT",
4549
protocol: url.protocol,
4650
hostname: url.hostname,
4751
path: url.pathname,
4852
headers: {
4953
"x-amz-date": new Date().toISOString(),
50-
"Content-Type": type,
54+
"Content-Type": contentType,
5155
"Content-Length": `${data.byteLength}`,
5256
"Cache-Control": "public, max-age=31536004,immutable",
5357
"x-amz-content-sha256": "UNSIGNED-PAYLOAD",

0 commit comments

Comments
 (0)