fix(AwsS3 Node): Fix handling of bucket with dot in name (#8475)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2024-01-30 17:05:59 +01:00 committed by GitHub
parent e643a126f4
commit 0febe62ad0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 15 deletions

View file

@ -300,7 +300,7 @@ export class AwsS3V2 implements INodeType {
headers['x-amz-request-payer'] = 'requester'; headers['x-amz-request-payer'] = 'requester';
} }
if (additionalFields.parentFolderKey) { if (additionalFields.parentFolderKey) {
path = `/${additionalFields.parentFolderKey}${folderName}/`; path = `${basePath}/${additionalFields.parentFolderKey}/${folderName}/`;
} }
if (additionalFields.storageClass) { if (additionalFields.storageClass) {
headers['x-amz-storage-class'] = snakeCase( headers['x-amz-storage-class'] = snakeCase(
@ -778,7 +778,7 @@ export class AwsS3V2 implements INodeType {
const additionalFields = this.getNodeParameter('additionalFields', i); const additionalFields = this.getNodeParameter('additionalFields', i);
const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject) const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject)
.tagsValues as IDataObject[]; .tagsValues as IDataObject[];
let path = `${basePath}/`; let path = `${basePath}/${fileName}`;
let body; let body;
const multipartHeaders: IDataObject = {}; const multipartHeaders: IDataObject = {};
@ -788,9 +788,7 @@ export class AwsS3V2 implements INodeType {
neededHeaders['x-amz-request-payer'] = 'requester'; neededHeaders['x-amz-request-payer'] = 'requester';
} }
if (additionalFields.parentFolderKey) { if (additionalFields.parentFolderKey) {
path = `${additionalFields.parentFolderKey}/${fileName}`; path = `${basePath}/${additionalFields.parentFolderKey}/${fileName}`;
} else {
path = `${fileName}`;
} }
if (additionalFields.storageClass) { if (additionalFields.storageClass) {
multipartHeaders['x-amz-storage-class'] = snakeCase( multipartHeaders['x-amz-storage-class'] = snakeCase(
@ -877,7 +875,7 @@ export class AwsS3V2 implements INodeType {
this, this,
servicePath, servicePath,
'POST', 'POST',
`/${path}?uploads`, `${path}?uploads`,
body, body,
qs, qs,
{ ...neededHeaders, ...multipartHeaders }, { ...neededHeaders, ...multipartHeaders },
@ -899,7 +897,7 @@ export class AwsS3V2 implements INodeType {
this, this,
servicePath, servicePath,
'PUT', 'PUT',
`/${path}?partNumber=${part}&uploadId=${uploadId}`, `${path}?partNumber=${part}&uploadId=${uploadId}`,
chunk, chunk,
qs, qs,
listHeaders, listHeaders,
@ -913,7 +911,7 @@ export class AwsS3V2 implements INodeType {
this, this,
servicePath, servicePath,
'DELETE', 'DELETE',
`/${path}?uploadId=${uploadId}`, `${path}?uploadId=${uploadId}`,
); );
} catch (err) { } catch (err) {
throw new NodeOperationError(this.getNode(), err as Error); throw new NodeOperationError(this.getNode(), err as Error);
@ -926,7 +924,7 @@ export class AwsS3V2 implements INodeType {
this, this,
servicePath, servicePath,
'GET', 'GET',
`/${path}?max-parts=${900}&part-number-marker=0&uploadId=${uploadId}`, `${path}?max-parts=${900}&part-number-marker=0&uploadId=${uploadId}`,
'', '',
qs, qs,
{ ...neededHeaders }, { ...neededHeaders },
@ -978,7 +976,7 @@ export class AwsS3V2 implements INodeType {
this, this,
servicePath, servicePath,
'POST', 'POST',
`/${path}?uploadId=${uploadId}`, `${path}?uploadId=${uploadId}`,
data, data,
qs, qs,
{ {
@ -1015,7 +1013,7 @@ export class AwsS3V2 implements INodeType {
this, this,
servicePath, servicePath,
'PUT', 'PUT',
`/${path || binaryPropertyData.fileName}`, path,
body, body,
qs, qs,
headers, headers,
@ -1043,7 +1041,7 @@ export class AwsS3V2 implements INodeType {
this, this,
servicePath, servicePath,
'PUT', 'PUT',
`/${path}`, path,
body, body,
qs, qs,
{ ...headers }, { ...headers },

View file

@ -23,7 +23,7 @@
{ {
"parameters": { "parameters": {
"operation": "upload", "operation": "upload",
"bucketName": "bucket", "bucketName": "buc.ket",
"fileName": "binary.json", "fileName": "binary.json",
"additionalFields": {} "additionalFields": {}
}, },

View file

@ -14,11 +14,11 @@ describe('Test S3 V2 Node', () => {
await initBinaryDataService(); await initBinaryDataService();
nock.disableNetConnect(); nock.disableNetConnect();
mock = nock('https://bucket.s3.eu-central-1.amazonaws.com'); mock = nock('https://s3.eu-central-1.amazonaws.com/buc.ket');
}); });
beforeEach(async () => { beforeEach(async () => {
mock.get('/?location').reply( mock.get('?location').reply(
200, 200,
`<?xml version="1.0" encoding="UTF-8"?> `<?xml version="1.0" encoding="UTF-8"?>
<LocationConstraint> <LocationConstraint>