Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions packages/nodes-base/nodes/Aws/S3/V2/AwsS3V2.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class AwsS3V2 implements INodeType {
headers['x-amz-request-payer'] = 'requester';
}
if (additionalFields.parentFolderKey) {
path = `/${additionalFields.parentFolderKey}${folderName}/`;
path = `${basePath}/${additionalFields.parentFolderKey}/${folderName}/`;
}
if (additionalFields.storageClass) {
headers['x-amz-storage-class'] = snakeCase(
Expand Down Expand Up @@ -778,7 +778,7 @@ export class AwsS3V2 implements INodeType {
const additionalFields = this.getNodeParameter('additionalFields', i);
const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject)
.tagsValues as IDataObject[];
let path = `${basePath}/`;
let path = `${basePath}/${fileName}`;
let body;

const multipartHeaders: IDataObject = {};
Expand All @@ -788,9 +788,7 @@ export class AwsS3V2 implements INodeType {
neededHeaders['x-amz-request-payer'] = 'requester';
}
if (additionalFields.parentFolderKey) {
path = `${additionalFields.parentFolderKey}/${fileName}`;
} else {
path = `${fileName}`;
path = `${basePath}/${additionalFields.parentFolderKey}/${fileName}`;
}
if (additionalFields.storageClass) {
multipartHeaders['x-amz-storage-class'] = snakeCase(
Expand Down Expand Up @@ -877,7 +875,7 @@ export class AwsS3V2 implements INodeType {
this,
servicePath,
'POST',
`/${path}?uploads`,
`${path}?uploads`,
body,
qs,
{ ...neededHeaders, ...multipartHeaders },
Expand All @@ -899,7 +897,7 @@ export class AwsS3V2 implements INodeType {
this,
servicePath,
'PUT',
`/${path}?partNumber=${part}&uploadId=${uploadId}`,
`${path}?partNumber=${part}&uploadId=${uploadId}`,
chunk,
qs,
listHeaders,
Expand All @@ -913,7 +911,7 @@ export class AwsS3V2 implements INodeType {
this,
servicePath,
'DELETE',
`/${path}?uploadId=${uploadId}`,
`${path}?uploadId=${uploadId}`,
);
} catch (err) {
throw new NodeOperationError(this.getNode(), err as Error);
Expand All @@ -926,7 +924,7 @@ export class AwsS3V2 implements INodeType {
this,
servicePath,
'GET',
`/${path}?max-parts=${900}&part-number-marker=0&uploadId=${uploadId}`,
`${path}?max-parts=${900}&part-number-marker=0&uploadId=${uploadId}`,
'',
qs,
{ ...neededHeaders },
Expand Down Expand Up @@ -978,7 +976,7 @@ export class AwsS3V2 implements INodeType {
this,
servicePath,
'POST',
`/${path}?uploadId=${uploadId}`,
`${path}?uploadId=${uploadId}`,
data,
qs,
{
Expand Down Expand Up @@ -1015,7 +1013,7 @@ export class AwsS3V2 implements INodeType {
this,
servicePath,
'PUT',
`/${path || binaryPropertyData.fileName}`,
path,
body,
qs,
headers,
Expand Down Expand Up @@ -1043,7 +1041,7 @@ export class AwsS3V2 implements INodeType {
this,
servicePath,
'PUT',
`/${path}`,
path,
body,
qs,
{ ...headers },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
"parameters": {
"operation": "upload",
"bucketName": "bucket",
"bucketName": "buc.ket",
"fileName": "binary.json",
"additionalFields": {}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/Aws/S3/test/V2/AwsS3.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ describe('Test S3 V2 Node', () => {
await initBinaryDataService();

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 () => {
mock.get('/?location').reply(
mock.get('?location').reply(
200,
`<?xml version="1.0" encoding="UTF-8"?>
<LocationConstraint>
Expand Down
Loading