diff --git a/src/modules/coreHttpApi/controllers/FilesController.ts b/src/modules/coreHttpApi/controllers/FilesController.ts index 77cbc85a..136dc9fa 100644 --- a/src/modules/coreHttpApi/controllers/FilesController.ts +++ b/src/modules/coreHttpApi/controllers/FilesController.ts @@ -24,7 +24,7 @@ export class FilesController extends BaseController { const result = await this.transportServices.files.uploadOwnFile({ content: file?.buffer, expiresAt, - filename: file?.originalname, + filename: file?.originalname !== undefined ? Buffer.from(file.originalname, "latin1").toString("utf8") : undefined, mimetype: file?.mimetype, title, description diff --git a/test/files.test.ts b/test/files.test.ts index ca8a1bda..c486d3a7 100644 --- a/test/files.test.ts +++ b/test/files.test.ts @@ -25,6 +25,26 @@ describe("File Upload", () => { file = response.result; }); + test("can upload file with umlaut in title and filename", async () => { + const response = await client1.files.uploadOwnFile(await makeUploadRequest({ title: "ÄÖÜ", filename: "ÄÖÜ.txt" })); + + expect(response).toBeSuccessful(ValidationSchema.File); + + const file = response.result; + expect(file.title).toBe("ÄÖÜ"); + expect(file.filename).toBe("ÄÖÜ.txt"); + }); + + test("can upload file with space in title and filename", async () => { + const response = await client1.files.uploadOwnFile(await makeUploadRequest({ title: "a file", filename: "a file.txt" })); + + expect(response).toBeSuccessful(ValidationSchema.File); + + const file = response.result; + expect(file.title).toBe("a file"); + expect(file.filename).toBe("a file.txt"); + }); + test("can upload file without description", async () => { const response = await client1.files.uploadOwnFile({ title: "File Title",