1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-10-08 02:28:57 +03:00

Minor improvements to S3-Node

This commit is contained in:
Jan Oberhauser 2020-09-02 08:30:01 +02:00
parent a0f335b0c8
commit 248ccce5c3
6 changed files with 18 additions and 18 deletions

View File

@ -4,9 +4,9 @@ import {
} from 'n8n-workflow';
export class CustomS3Endpoint implements ICredentialType {
name = 'customS3Endpoint';
displayName = 'Custom S3';
export class S3 implements ICredentialType {
name = 's3';
displayName = 'S3';
properties = [
{
displayName: 'S3 endpoint',

View File

@ -23,7 +23,7 @@ import {
import {
IDataObject,
} from 'n8n-workflow';
} from 'n8n-workflow';
import { URL } from 'url';
@ -31,7 +31,7 @@ export async function s3ApiRequest(this: IHookFunctions | IExecuteFunctions | IL
let credentials;
credentials = this.getCredentials('customS3Endpoint');
credentials = this.getCredentials('s3');
if (credentials === undefined) {
throw new Error('No credentials got returned!');
@ -64,13 +64,13 @@ export async function s3ApiRequest(this: IHookFunctions | IExecuteFunctions | IL
body
};
sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim()});
sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim() });
const options: OptionsWithUri = {
headers: signOpts.headers,
method,
qs: query,
uri: endpoint,
uri: endpoint.toString(),
body: signOpts.body,
};

View File

@ -49,12 +49,12 @@ import {
export class S3 implements INodeType {
description: INodeTypeDescription = {
displayName: 'S3',
name: 'S3',
icon: 'file:generic-s3.png',
name: 's3',
icon: 'file:s3.png',
group: ['output'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Sends data to any S3-compatible services',
description: 'Sends data to any S3-compatible service',
defaults: {
name: 'S3',
color: '#d05b4b',
@ -63,7 +63,7 @@ export class S3 implements INodeType {
outputs: ['main'],
credentials: [
{
name: 'customS3Endpoint',
name: 's3',
required: true,
},
],
@ -117,7 +117,7 @@ export class S3 implements INodeType {
let credentials;
try {
credentials = this.getCredentials('customS3Endpoint');
credentials = this.getCredentials('s3');
} catch (error) {
throw new Error(error);
}
@ -274,10 +274,10 @@ export class S3 implements INodeType {
responseData = await s3ApiRequestSOAP.call(this, bucketName, 'DELETE', `/${folderKey}`, '', qs, {}, {}, region);
responseData = { deleted: [ { 'Key': folderKey } ] };
responseData = { deleted: [{ 'Key': folderKey }] };
} else {
// delete everything inside the folder
// delete everything inside the folder
const body: IDataObject = {
Delete: {
'$': {
@ -301,7 +301,7 @@ 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 };
}
@ -437,7 +437,7 @@ export class S3 implements INodeType {
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']) {
@ -462,7 +462,7 @@ export class S3 implements INodeType {
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') {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -52,7 +52,7 @@
"dist/credentials/CopperApi.credentials.js",
"dist/credentials/CalendlyApi.credentials.js",
"dist/credentials/CustomerIoApi.credentials.js",
"dist/credentials/CustomS3Endpoint.credentials.js",
"dist/credentials/S3.credentials.js",
"dist/credentials/CrateDb.credentials.js",
"dist/credentials/DisqusApi.credentials.js",
"dist/credentials/DriftApi.credentials.js",