fix: escape non-ascii characters in filenames in s3 file provider (#14209)

* escape non-ascii characters in filenames in s3 file provider

* fix url encoding
This commit is contained in:
Pedro Guzman
2025-12-04 18:37:56 +01:00
committed by GitHub
parent e3e3c725db
commit b7adfb225b
3 changed files with 25 additions and 3 deletions
@@ -1,5 +1,5 @@
import fs from "fs/promises"
import axios from "axios"
import fs from "fs/promises"
import { S3FileService } from "../../src/services/s3-file"
jest.setTimeout(100000)
@@ -82,6 +82,23 @@ describe.skip("S3 File Plugin", () => {
})
})
it("uploads a file with non-ascii characters in the name", async () => {
const fileContent = await fs.readFile(fixtureImagePath)
const fixtureAsBinary = fileContent.toString("base64")
const resp = await s3Service.upload({
filename: "catphoto-か.jpg",
mimeType: "image/jpeg",
content: fixtureAsBinary,
access: "private",
})
expect(resp).toEqual({
key: expect.stringMatching(/tests\/catphoto-か.*\.jpg/),
url: expect.stringMatching(/https:\/\/.*\/catphoto-%E3%81%8B.*\.jpg/),
})
})
it("gets a presigned upload URL and uploads a file successfully", async () => {
const fileContent = await fs.readFile(fixtureImagePath)
const fixtureAsBinary = fileContent.toString("binary")