mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
fix(core): Fix object store support for non-latin chars (#17383)
Co-authored-by: easy <e@mpnew.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import {
|
||||
DeleteObjectCommand,
|
||||
DeleteObjectsCommand,
|
||||
@@ -178,6 +179,33 @@ describe('ObjectStoreService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should encode filename with non-ASCII characters in metadata', async () => {
|
||||
const metadata = {
|
||||
fileName: 'Order Form - Gunes Ekspres Havacılık A.Ş.',
|
||||
mimeType: 'text/plain',
|
||||
};
|
||||
|
||||
mockS3Send.mockResolvedValueOnce({});
|
||||
|
||||
await objectStoreService.put(fileId, mockBuffer, metadata);
|
||||
|
||||
const commandCaptor = captor<PutObjectCommand>();
|
||||
expect(mockS3Send).toHaveBeenCalledWith(commandCaptor);
|
||||
const command = commandCaptor.value;
|
||||
expect(command).toBeInstanceOf(PutObjectCommand);
|
||||
expect(command.input).toEqual({
|
||||
Bucket: 'test-bucket',
|
||||
Key: fileId,
|
||||
Body: mockBuffer,
|
||||
ContentLength: mockBuffer.length,
|
||||
ContentMD5: 'yh6gLBC3w39CW5t92G1eEQ==',
|
||||
ContentType: 'text/plain',
|
||||
Metadata: {
|
||||
filename: 'Order%20Form%20-%20Gunes%20Ekspres%20Havac%C4%B1l%C4%B1k%20A.%C5%9E.',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error on request failure', async () => {
|
||||
const metadata = { fileName: 'file.txt', mimeType: 'text/plain' };
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ export class ObjectStoreService {
|
||||
};
|
||||
|
||||
if (metadata.fileName) {
|
||||
params.Metadata = { filename: metadata.fileName };
|
||||
params.Metadata = { filename: encodeURIComponent(metadata.fileName) };
|
||||
}
|
||||
|
||||
if (metadata.mimeType) {
|
||||
@@ -174,7 +174,8 @@ export class ObjectStoreService {
|
||||
// Add metadata with the expected prefix format
|
||||
if (response.Metadata) {
|
||||
Object.entries(response.Metadata).forEach(([key, value]) => {
|
||||
headers[`x-amz-meta-${key.toLowerCase()}`] = value;
|
||||
headers[`x-amz-meta-${key.toLowerCase()}`] =
|
||||
key === 'filename' ? decodeURIComponent(value) : value;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user