mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
⚡ Small improvements
This commit is contained in:
parent
ed52b67329
commit
bedc7f88e4
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue