fix S3 URL escaping (#14220)
This commit is contained in:
@@ -99,6 +99,23 @@ describe.skip("S3 File Plugin", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("uploads a file with special URL characters in the name", async () => {
|
||||||
|
const fileContent = await fs.readFile(fixtureImagePath)
|
||||||
|
const fixtureAsBinary = fileContent.toString("base64")
|
||||||
|
|
||||||
|
const resp = await s3Service.upload({
|
||||||
|
filename: "cat?photo.jpg",
|
||||||
|
mimeType: "image/jpeg",
|
||||||
|
content: fixtureAsBinary,
|
||||||
|
access: "private",
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(resp).toEqual({
|
||||||
|
key: expect.stringMatching(/tests\/catphoto.*\.jpg/),
|
||||||
|
url: expect.stringMatching(/https:\/\/.*\/cat%3Fphoto.*\.jpg/),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it("gets a presigned upload URL and uploads a file successfully", async () => {
|
it("gets a presigned upload URL and uploads a file successfully", async () => {
|
||||||
const fileContent = await fs.readFile(fixtureImagePath)
|
const fileContent = await fs.readFile(fixtureImagePath)
|
||||||
const fixtureAsBinary = fileContent.toString("binary")
|
const fixtureAsBinary = fileContent.toString("binary")
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export class S3FileService extends AbstractFileProviderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: `${this.config_.fileUrl}/${encodeURI(fileKey)}`,
|
url: `${this.config_.fileUrl}/${encodeURIComponent(fileKey)}`,
|
||||||
key: fileKey,
|
key: fileKey,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user