diff --git a/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts b/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts index 0dff8f8619..cc7d141e68 100644 --- a/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts +++ b/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts @@ -337,12 +337,11 @@ export class AwsS3 implements INodeType { if (resource === 'file') { //https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html if (operation === 'copy') { - const source = this.getNodeParameter('source', i) as string; - const bucketName = this.getNodeParameter('bucketName', i) as string; - const destination = this.getNodeParameter('destination', i) as string; + const sourcePath = this.getNodeParameter('sourcePath', i) as string; + const destinationPath = this.getNodeParameter('destinationPath', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - headers['x-amz-copy-source'] = source; + headers['x-amz-copy-source'] = sourcePath; if (additionalFields.requesterPays) { headers['x-amz-request-payer'] = 'requester'; @@ -399,11 +398,17 @@ export class AwsS3 implements INodeType { headers['x-amz-metadata-directive'] = (additionalFields.metadataDirective as string).toUpperCase(); } + const destinationParts = destinationPath.split('/'); + + const bucketName = destinationParts[1]; + + const destination = `/${destinationParts.slice(2, destinationParts.length).join('/')}`; + responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' }); const region = responseData.LocationConstraint._; - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'PUT', `${destination}`, '', qs, headers, {}, region); + responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'PUT', destination, '', qs, headers, {}, region); returnData.push(responseData.CopyObjectResult); } diff --git a/packages/nodes-base/nodes/Aws/S3/FileDescription.ts b/packages/nodes-base/nodes/Aws/S3/FileDescription.ts index b1c6d133ac..17e7642ff2 100644 --- a/packages/nodes-base/nodes/Aws/S3/FileDescription.ts +++ b/packages/nodes-base/nodes/Aws/S3/FileDescription.ts @@ -52,8 +52,8 @@ export const fileFields = [ /* file:copy */ /* -------------------------------------------------------------------------- */ { - displayName: 'Source', - name: 'source', + displayName: 'Source Path', + name: 'sourcePath', type: 'string', required: true, default: '', @@ -71,11 +71,12 @@ export const fileFields = [ description: 'The name of the source bucket and key name of the source object, separated by a slash (/)', }, { - displayName: 'Bucket Name', - name: 'bucketName', + displayName: 'Destination Path', + name: 'destinationPath', type: 'string', required: true, default: '', + placeholder: '/bucket/my-second-image.jpg', displayOptions: { show: { resource: [ @@ -86,26 +87,7 @@ export const fileFields = [ ], }, }, - description: 'The name of the destination bucket.', - }, - { - displayName: 'Destination', - name: 'destination', - type: 'string', - required: true, - default: '', - placeholder: '/my-second-image.jpg', - displayOptions: { - show: { - resource: [ - 'file', - ], - operation: [ - 'copy', - ], - }, - }, - description: 'The key of the destination object.', + description: 'The name of the destination bucket and key name of the destination object, separated by a slash (/)', }, { displayName: 'Additional Fields',