mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
paramCase,
|
||||
snakeCase,
|
||||
} from 'change-case';
|
||||
import { paramCase, snakeCase } from 'change-case';
|
||||
|
||||
import { createHash } from 'crypto';
|
||||
|
||||
@@ -19,26 +16,13 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
bucketFields,
|
||||
bucketOperations,
|
||||
} from '../Aws/S3/BucketDescription';
|
||||
import { bucketFields, bucketOperations } from '../Aws/S3/BucketDescription';
|
||||
|
||||
import {
|
||||
folderFields,
|
||||
folderOperations,
|
||||
} from '../Aws/S3/FolderDescription';
|
||||
import { folderFields, folderOperations } from '../Aws/S3/FolderDescription';
|
||||
|
||||
import {
|
||||
fileFields,
|
||||
fileOperations,
|
||||
} from '../Aws/S3/FileDescription';
|
||||
import { fileFields, fileOperations } from '../Aws/S3/FileDescription';
|
||||
|
||||
import {
|
||||
s3ApiRequestREST,
|
||||
s3ApiRequestSOAP,
|
||||
s3ApiRequestSOAPAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { s3ApiRequestREST, s3ApiRequestSOAP, s3ApiRequestSOAPAllItems } from './GenericFunctions';
|
||||
|
||||
export class S3 implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -108,7 +92,6 @@ export class S3 implements INodeType {
|
||||
if (resource === 'bucket') {
|
||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html
|
||||
if (operation === 'create') {
|
||||
|
||||
let credentials;
|
||||
|
||||
try {
|
||||
@@ -123,7 +106,8 @@ export class S3 implements INodeType {
|
||||
headers['x-amz-acl'] = paramCase(additionalFields.acl as string);
|
||||
}
|
||||
if (additionalFields.bucketObjectLockEnabled) {
|
||||
headers['x-amz-bucket-object-lock-enabled'] = additionalFields.bucketObjectLockEnabled as boolean;
|
||||
headers['x-amz-bucket-object-lock-enabled'] =
|
||||
additionalFields.bucketObjectLockEnabled as boolean;
|
||||
}
|
||||
if (additionalFields.grantFullControl) {
|
||||
headers['x-amz-grant-full-control'] = '';
|
||||
@@ -148,7 +132,7 @@ export class S3 implements INodeType {
|
||||
|
||||
const body: IDataObject = {
|
||||
CreateBucketConfiguration: {
|
||||
'$': {
|
||||
$: {
|
||||
xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/',
|
||||
},
|
||||
},
|
||||
@@ -161,7 +145,15 @@ export class S3 implements INodeType {
|
||||
const builder = new Builder();
|
||||
data = builder.buildObject(body);
|
||||
}
|
||||
responseData = await s3ApiRequestSOAP.call(this, `${name}`, 'PUT', '', data, qs, headers);
|
||||
responseData = await s3ApiRequestSOAP.call(
|
||||
this,
|
||||
`${name}`,
|
||||
'PUT',
|
||||
'',
|
||||
data,
|
||||
qs,
|
||||
headers,
|
||||
);
|
||||
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
@@ -169,10 +161,24 @@ export class S3 implements INodeType {
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||
if (returnAll) {
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListAllMyBucketsResult.Buckets.Bucket', '', 'GET', '');
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListAllMyBucketsResult.Buckets.Bucket',
|
||||
'',
|
||||
'GET',
|
||||
'',
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListAllMyBucketsResult.Buckets.Bucket', '', 'GET', '', '', qs);
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListAllMyBucketsResult.Buckets.Bucket',
|
||||
'',
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.slice(0, qs.limit);
|
||||
}
|
||||
returnData.push.apply(returnData, responseData);
|
||||
@@ -210,16 +216,38 @@ export class S3 implements INodeType {
|
||||
|
||||
qs['list-type'] = 2;
|
||||
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' });
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._ as string;
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
bucketName,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
} else {
|
||||
qs['max-keys'] = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await s3ApiRequestSOAP.call(
|
||||
this,
|
||||
bucketName,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
responseData = responseData.ListBucketResult.Contents;
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
@@ -244,13 +272,27 @@ export class S3 implements INodeType {
|
||||
path = `/${additionalFields.parentFolderKey}${folderName}/`;
|
||||
}
|
||||
if (additionalFields.storageClass) {
|
||||
headers['x-amz-storage-class'] = (snakeCase(additionalFields.storageClass as string)).toUpperCase();
|
||||
headers['x-amz-storage-class'] = snakeCase(
|
||||
additionalFields.storageClass as string,
|
||||
).toUpperCase();
|
||||
}
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' });
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'PUT', path, '', qs, headers, {}, region);
|
||||
responseData = await s3ApiRequestSOAP.call(
|
||||
this,
|
||||
bucketName,
|
||||
'PUT',
|
||||
path,
|
||||
'',
|
||||
qs,
|
||||
headers,
|
||||
{},
|
||||
region,
|
||||
);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html
|
||||
@@ -258,24 +300,45 @@ export class S3 implements INodeType {
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
const folderKey = this.getNodeParameter('folderKey', i) as string;
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' });
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '/', '', { 'list-type': 2, prefix: folderKey }, {}, {}, region);
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
bucketName,
|
||||
'GET',
|
||||
'/',
|
||||
'',
|
||||
{ 'list-type': 2, prefix: folderKey },
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
|
||||
// folder empty then just delete it
|
||||
if (responseData.length === 0) {
|
||||
responseData = await s3ApiRequestSOAP.call(
|
||||
this,
|
||||
bucketName,
|
||||
'DELETE',
|
||||
`/${folderKey}`,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'DELETE', `/${folderKey}`, '', qs, {}, {}, region);
|
||||
|
||||
responseData = { deleted: [{ 'Key': folderKey }] };
|
||||
|
||||
responseData = { deleted: [{ Key: folderKey }] };
|
||||
} else {
|
||||
// delete everything inside the folder
|
||||
const body: IDataObject = {
|
||||
Delete: {
|
||||
'$': {
|
||||
$: {
|
||||
xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/',
|
||||
},
|
||||
Object: [],
|
||||
@@ -296,7 +359,17 @@ export class S3 implements INodeType {
|
||||
|
||||
headers['Content-Type'] = 'application/xml';
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'POST', '/', data, { delete: '' }, headers, {}, region);
|
||||
responseData = await s3ApiRequestSOAP.call(
|
||||
this,
|
||||
bucketName,
|
||||
'POST',
|
||||
'/',
|
||||
data,
|
||||
{ delete: '' },
|
||||
headers,
|
||||
{},
|
||||
region,
|
||||
);
|
||||
|
||||
responseData = { deleted: responseData.DeleteResult.Deleted };
|
||||
}
|
||||
@@ -318,18 +391,45 @@ export class S3 implements INodeType {
|
||||
|
||||
qs['list-type'] = 2;
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' });
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
bucketName,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
bucketName,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
responseData = responseData.filter((e: IDataObject) => (e.Key as string).endsWith('/') && e.Size === '0' && e.Key !== options.folderKey);
|
||||
responseData = responseData.filter(
|
||||
(e: IDataObject) =>
|
||||
(e.Key as string).endsWith('/') && e.Size === '0' && e.Key !== options.folderKey,
|
||||
);
|
||||
if (qs.limit) {
|
||||
responseData = responseData.splice(0, qs.limit as number);
|
||||
}
|
||||
@@ -350,7 +450,9 @@ export class S3 implements INodeType {
|
||||
headers['x-amz-request-payer'] = 'requester';
|
||||
}
|
||||
if (additionalFields.storageClass) {
|
||||
headers['x-amz-storage-class'] = (snakeCase(additionalFields.storageClass as string)).toUpperCase();
|
||||
headers['x-amz-storage-class'] = snakeCase(
|
||||
additionalFields.storageClass as string,
|
||||
).toUpperCase();
|
||||
}
|
||||
if (additionalFields.acl) {
|
||||
headers['x-amz-acl'] = paramCase(additionalFields.acl as string);
|
||||
@@ -368,37 +470,52 @@ export class S3 implements INodeType {
|
||||
headers['x-amz-grant-write-acp'] = '';
|
||||
}
|
||||
if (additionalFields.lockLegalHold) {
|
||||
headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean) ? 'ON' : 'OFF';
|
||||
headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean)
|
||||
? 'ON'
|
||||
: 'OFF';
|
||||
}
|
||||
if (additionalFields.lockMode) {
|
||||
headers['x-amz-object-lock-mode'] = (additionalFields.lockMode as string).toUpperCase();
|
||||
headers['x-amz-object-lock-mode'] = (
|
||||
additionalFields.lockMode as string
|
||||
).toUpperCase();
|
||||
}
|
||||
if (additionalFields.lockRetainUntilDate) {
|
||||
headers['x-amz-object-lock-retain-until-date'] = additionalFields.lockRetainUntilDate as string;
|
||||
headers['x-amz-object-lock-retain-until-date'] =
|
||||
additionalFields.lockRetainUntilDate as string;
|
||||
}
|
||||
if (additionalFields.serverSideEncryption) {
|
||||
headers['x-amz-server-side-encryption'] = additionalFields.serverSideEncryption as string;
|
||||
headers['x-amz-server-side-encryption'] =
|
||||
additionalFields.serverSideEncryption as string;
|
||||
}
|
||||
if (additionalFields.encryptionAwsKmsKeyId) {
|
||||
headers['x-amz-server-side-encryption-aws-kms-key-id'] = additionalFields.encryptionAwsKmsKeyId as string;
|
||||
headers['x-amz-server-side-encryption-aws-kms-key-id'] =
|
||||
additionalFields.encryptionAwsKmsKeyId as string;
|
||||
}
|
||||
if (additionalFields.serverSideEncryptionContext) {
|
||||
headers['x-amz-server-side-encryption-context'] = additionalFields.serverSideEncryptionContext as string;
|
||||
headers['x-amz-server-side-encryption-context'] =
|
||||
additionalFields.serverSideEncryptionContext as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerAlgorithm) {
|
||||
headers['x-amz-server-side-encryption-customer-algorithm'] = additionalFields.serversideEncryptionCustomerAlgorithm as string;
|
||||
headers['x-amz-server-side-encryption-customer-algorithm'] =
|
||||
additionalFields.serversideEncryptionCustomerAlgorithm as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerKey) {
|
||||
headers['x-amz-server-side-encryption-customer-key'] = additionalFields.serversideEncryptionCustomerKey as string;
|
||||
headers['x-amz-server-side-encryption-customer-key'] =
|
||||
additionalFields.serversideEncryptionCustomerKey as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerKeyMD5) {
|
||||
headers['x-amz-server-side-encryption-customer-key-MD5'] = additionalFields.serversideEncryptionCustomerKeyMD5 as string;
|
||||
headers['x-amz-server-side-encryption-customer-key-MD5'] =
|
||||
additionalFields.serversideEncryptionCustomerKeyMD5 as string;
|
||||
}
|
||||
if (additionalFields.taggingDirective) {
|
||||
headers['x-amz-tagging-directive'] = (additionalFields.taggingDirective as string).toUpperCase();
|
||||
headers['x-amz-tagging-directive'] = (
|
||||
additionalFields.taggingDirective as string
|
||||
).toUpperCase();
|
||||
}
|
||||
if (additionalFields.metadataDirective) {
|
||||
headers['x-amz-metadata-directive'] = (additionalFields.metadataDirective as string).toUpperCase();
|
||||
headers['x-amz-metadata-directive'] = (
|
||||
additionalFields.metadataDirective as string
|
||||
).toUpperCase();
|
||||
}
|
||||
|
||||
const destinationParts = destinationPath.split('/');
|
||||
@@ -407,17 +524,27 @@ export class S3 implements INodeType {
|
||||
|
||||
const destination = `/${destinationParts.slice(2, destinationParts.length).join('/')}`;
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' });
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'PUT', destination, '', qs, headers, {}, region);
|
||||
responseData = await s3ApiRequestSOAP.call(
|
||||
this,
|
||||
bucketName,
|
||||
'PUT',
|
||||
destination,
|
||||
'',
|
||||
qs,
|
||||
headers,
|
||||
{},
|
||||
region,
|
||||
);
|
||||
returnData.push(responseData.CopyObjectResult);
|
||||
|
||||
}
|
||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
|
||||
if (operation === 'download') {
|
||||
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
|
||||
const fileKey = this.getNodeParameter('fileKey', i) as string;
|
||||
@@ -425,14 +552,29 @@ export class S3 implements INodeType {
|
||||
const fileName = fileKey.split('/')[fileKey.split('/').length - 1];
|
||||
|
||||
if (fileKey.substring(fileKey.length - 1) === '/') {
|
||||
throw new NodeOperationError(this.getNode(), 'Downloding a whole directory is not yet supported, please provide a file key');
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Downloding a whole directory is not yet supported, please provide a file key',
|
||||
);
|
||||
}
|
||||
|
||||
let region = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' });
|
||||
let region = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
region = region.LocationConstraint._;
|
||||
|
||||
const response = await s3ApiRequestREST.call(this, bucketName, 'GET', `/${fileKey}`, '', qs, {}, { encoding: null, resolveWithFullResponse: true }, region);
|
||||
const response = await s3ApiRequestREST.call(
|
||||
this,
|
||||
bucketName,
|
||||
'GET',
|
||||
`/${fileKey}`,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{ encoding: null, resolveWithFullResponse: true },
|
||||
region,
|
||||
);
|
||||
|
||||
let mimeType: string | undefined;
|
||||
if (response.headers['content-type']) {
|
||||
@@ -453,11 +595,18 @@ export class S3 implements INodeType {
|
||||
|
||||
items[i] = newItem;
|
||||
|
||||
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
const dataPropertyNameDownload = this.getNodeParameter(
|
||||
'binaryPropertyName',
|
||||
i,
|
||||
) as string;
|
||||
|
||||
const data = Buffer.from(response.body as string, 'utf8');
|
||||
|
||||
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType);
|
||||
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(
|
||||
data as unknown as Buffer,
|
||||
fileName,
|
||||
mimeType,
|
||||
);
|
||||
}
|
||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html
|
||||
if (operation === 'delete') {
|
||||
@@ -471,11 +620,23 @@ export class S3 implements INodeType {
|
||||
qs.versionId = options.versionId as string;
|
||||
}
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' });
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'DELETE', `/${fileKey}`, '', qs, {}, {}, region);
|
||||
responseData = await s3ApiRequestSOAP.call(
|
||||
this,
|
||||
bucketName,
|
||||
'DELETE',
|
||||
`/${fileKey}`,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
@@ -497,19 +658,45 @@ export class S3 implements INodeType {
|
||||
|
||||
qs['list-type'] = 2;
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' });
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
bucketName,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await s3ApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
bucketName,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
responseData = responseData.filter((e: IDataObject) => !(e.Key as string).endsWith('/') && e.Size !== '0');
|
||||
responseData = responseData.filter(
|
||||
(e: IDataObject) => !(e.Key as string).endsWith('/') && e.Size !== '0',
|
||||
);
|
||||
if (qs.limit) {
|
||||
responseData = responseData.splice(0, qs.limit as number);
|
||||
}
|
||||
@@ -522,7 +709,8 @@ export class S3 implements INodeType {
|
||||
const fileName = this.getNodeParameter('fileName', i) as string;
|
||||
const isBinaryData = this.getNodeParameter('binaryData', i) as boolean;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject).tagsValues as IDataObject[];
|
||||
const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject)
|
||||
.tagsValues as IDataObject[];
|
||||
let path = '/';
|
||||
let body;
|
||||
|
||||
@@ -534,7 +722,9 @@ export class S3 implements INodeType {
|
||||
path = `/${additionalFields.parentFolderKey}/`;
|
||||
}
|
||||
if (additionalFields.storageClass) {
|
||||
headers['x-amz-storage-class'] = (snakeCase(additionalFields.storageClass as string)).toUpperCase();
|
||||
headers['x-amz-storage-class'] = snakeCase(
|
||||
additionalFields.storageClass as string,
|
||||
).toUpperCase();
|
||||
}
|
||||
if (additionalFields.acl) {
|
||||
headers['x-amz-acl'] = paramCase(additionalFields.acl as string);
|
||||
@@ -552,39 +742,54 @@ export class S3 implements INodeType {
|
||||
headers['x-amz-grant-write-acp'] = '';
|
||||
}
|
||||
if (additionalFields.lockLegalHold) {
|
||||
headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean) ? 'ON' : 'OFF';
|
||||
headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean)
|
||||
? 'ON'
|
||||
: 'OFF';
|
||||
}
|
||||
if (additionalFields.lockMode) {
|
||||
headers['x-amz-object-lock-mode'] = (additionalFields.lockMode as string).toUpperCase();
|
||||
headers['x-amz-object-lock-mode'] = (
|
||||
additionalFields.lockMode as string
|
||||
).toUpperCase();
|
||||
}
|
||||
if (additionalFields.lockRetainUntilDate) {
|
||||
headers['x-amz-object-lock-retain-until-date'] = additionalFields.lockRetainUntilDate as string;
|
||||
headers['x-amz-object-lock-retain-until-date'] =
|
||||
additionalFields.lockRetainUntilDate as string;
|
||||
}
|
||||
if (additionalFields.serverSideEncryption) {
|
||||
headers['x-amz-server-side-encryption'] = additionalFields.serverSideEncryption as string;
|
||||
headers['x-amz-server-side-encryption'] =
|
||||
additionalFields.serverSideEncryption as string;
|
||||
}
|
||||
if (additionalFields.encryptionAwsKmsKeyId) {
|
||||
headers['x-amz-server-side-encryption-aws-kms-key-id'] = additionalFields.encryptionAwsKmsKeyId as string;
|
||||
headers['x-amz-server-side-encryption-aws-kms-key-id'] =
|
||||
additionalFields.encryptionAwsKmsKeyId as string;
|
||||
}
|
||||
if (additionalFields.serverSideEncryptionContext) {
|
||||
headers['x-amz-server-side-encryption-context'] = additionalFields.serverSideEncryptionContext as string;
|
||||
headers['x-amz-server-side-encryption-context'] =
|
||||
additionalFields.serverSideEncryptionContext as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerAlgorithm) {
|
||||
headers['x-amz-server-side-encryption-customer-algorithm'] = additionalFields.serversideEncryptionCustomerAlgorithm as string;
|
||||
headers['x-amz-server-side-encryption-customer-algorithm'] =
|
||||
additionalFields.serversideEncryptionCustomerAlgorithm as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerKey) {
|
||||
headers['x-amz-server-side-encryption-customer-key'] = additionalFields.serversideEncryptionCustomerKey as string;
|
||||
headers['x-amz-server-side-encryption-customer-key'] =
|
||||
additionalFields.serversideEncryptionCustomerKey as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerKeyMD5) {
|
||||
headers['x-amz-server-side-encryption-customer-key-MD5'] = additionalFields.serversideEncryptionCustomerKeyMD5 as string;
|
||||
headers['x-amz-server-side-encryption-customer-key-MD5'] =
|
||||
additionalFields.serversideEncryptionCustomerKeyMD5 as string;
|
||||
}
|
||||
if (tagsValues) {
|
||||
const tags: string[] = [];
|
||||
tagsValues.forEach((o: IDataObject) => { tags.push(`${o.key}=${o.value}`); });
|
||||
tagsValues.forEach((o: IDataObject) => {
|
||||
tags.push(`${o.key}=${o.value}`);
|
||||
});
|
||||
headers['x-amz-tagging'] = tags.join('&');
|
||||
}
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' });
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
@@ -592,11 +797,17 @@ export class S3 implements INodeType {
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
|
||||
|
||||
if (items[i].binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
|
||||
if ((items[i].binary as IBinaryKeyData)[binaryPropertyName] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${binaryPropertyName}" does not exists on item!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
@@ -606,10 +817,18 @@ export class S3 implements INodeType {
|
||||
|
||||
headers['Content-MD5'] = createHash('md5').update(body).digest('base64');
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'PUT', `${path}${fileName || binaryData.fileName}`, body, qs, headers, {}, region);
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(
|
||||
this,
|
||||
bucketName,
|
||||
'PUT',
|
||||
`${path}${fileName || binaryData.fileName}`,
|
||||
body,
|
||||
qs,
|
||||
headers,
|
||||
{},
|
||||
region,
|
||||
);
|
||||
} else {
|
||||
|
||||
const fileContent = this.getNodeParameter('fileContent', i) as string;
|
||||
|
||||
body = Buffer.from(fileContent, 'utf8');
|
||||
@@ -618,7 +837,17 @@ export class S3 implements INodeType {
|
||||
|
||||
headers['Content-MD5'] = createHash('md5').update(fileContent).digest('base64');
|
||||
|
||||
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'PUT', `${path}${fileName}`, body, qs, headers, {}, region);
|
||||
responseData = await s3ApiRequestSOAP.call(
|
||||
this,
|
||||
bucketName,
|
||||
'PUT',
|
||||
`${path}${fileName}`,
|
||||
body,
|
||||
qs,
|
||||
headers,
|
||||
{},
|
||||
region,
|
||||
);
|
||||
}
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
@@ -627,7 +856,7 @@ export class S3 implements INodeType {
|
||||
if (this.continueOnFail()) {
|
||||
if (resource === 'file' && operation === 'download') {
|
||||
items[i].json = { error: error.message };
|
||||
}else {
|
||||
} else {
|
||||
returnData.push({ error: error.message });
|
||||
}
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user