mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
Create generic S3 node
This commit is contained in:
@@ -31,14 +31,8 @@ export async function s3ApiRequest(this: IHookFunctions | IExecuteFunctions | IL
|
||||
|
||||
let credentials;
|
||||
|
||||
const endpointType = this.getNodeParameter('endpoint', 0);
|
||||
|
||||
try {
|
||||
if (endpointType === 'aws') {
|
||||
credentials = this.getCredentials('aws');
|
||||
} else {
|
||||
credentials = this.getCredentials('customS3Endpoint');
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
@@ -47,19 +41,8 @@ export async function s3ApiRequest(this: IHookFunctions | IExecuteFunctions | IL
|
||||
throw new Error('No credentials got returned!');
|
||||
}
|
||||
|
||||
if (endpointType === "customS3Endpoint" && !(credentials.endpoint as string).startsWith('http')) {
|
||||
throw new Error('HTTP(S) Scheme is required in endpoint definition');
|
||||
}
|
||||
|
||||
const endpoint = new URL(endpointType === 'aws' ? `https://${bucket}.s3.${region || credentials.region}.amazonaws.com` : credentials.endpoint as string);
|
||||
|
||||
if (bucket && endpointType === 'customS3Endpoint') {
|
||||
if (credentials.forcePathStyle) {
|
||||
path = `/${bucket}${path}`;
|
||||
} else {
|
||||
endpoint.host = `${bucket}.${endpoint.host}`;
|
||||
}
|
||||
}
|
||||
const endpoint = new URL(`https://${bucket}.s3.${region || credentials.region}.amazonaws.com`);
|
||||
|
||||
endpoint.pathname = path;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user