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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user