n8n-nodes-binary-to-url 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import type { Icon, ICredentialType, INodeProperties } from 'n8n-workflow';
2
- export declare class S3StorageApi implements ICredentialType {
1
+ import type { ICredentialType, INodeProperties, Icon } from 'n8n-workflow';
2
+ export declare class S3Api implements ICredentialType {
3
3
  name: string;
4
4
  displayName: string;
5
5
  icon: Icon;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.S3Api = void 0;
4
+ class S3Api {
5
+ constructor() {
6
+ this.name = 's3Api';
7
+ this.displayName = 'S3';
8
+ this.icon = 'file:../icons/BinaryToUrl.svg';
9
+ this.documentationUrl = 'https://docs.aws.amazon.com/AmazonS3/latest/userguide/AccessCredentials.html';
10
+ this.properties = [
11
+ {
12
+ displayName: 'S3 Endpoint',
13
+ name: 'endpoint',
14
+ type: 'string',
15
+ default: '',
16
+ description: 'S3-compatible service endpoint (e.g., https://s3.amazonaws.com, https://minio.example.com)',
17
+ },
18
+ {
19
+ displayName: 'Region',
20
+ name: 'region',
21
+ type: 'string',
22
+ default: 'us-east-1',
23
+ description: 'AWS region or custom region for S3-compatible service',
24
+ },
25
+ {
26
+ displayName: 'Access Key ID',
27
+ name: 'accessKeyId',
28
+ type: 'string',
29
+ default: '',
30
+ },
31
+ {
32
+ displayName: 'Secret Access Key',
33
+ name: 'secretAccessKey',
34
+ type: 'string',
35
+ default: '',
36
+ typeOptions: {
37
+ password: true,
38
+ },
39
+ },
40
+ {
41
+ displayName: 'Force Path Style',
42
+ name: 'forcePathStyle',
43
+ type: 'boolean',
44
+ default: false,
45
+ description: 'Use path-style addressing (required for MinIO, DigitalOcean Spaces, etc.)',
46
+ },
47
+ ];
48
+ this.test = {
49
+ request: {
50
+ baseURL: '={{$credentials.endpoint}}',
51
+ url: '=/',
52
+ method: 'GET',
53
+ },
54
+ };
55
+ }
56
+ }
57
+ exports.S3Api = S3Api;
@@ -6,34 +6,42 @@ const S3Storage_1 = require("./S3Storage");
6
6
  var S3Storage_2 = require("./S3Storage");
7
7
  Object.defineProperty(exports, "S3Storage", { enumerable: true, get: function () { return S3Storage_2.S3Storage; } });
8
8
  async function createStorageDriver(context, bucket) {
9
- const credentials = await context.getCredentials('s3StorageApi');
9
+ const credentials = await context.getCredentials('s3Api');
10
10
  if (!credentials) {
11
11
  throw new Error('No S3 credentials found. Please configure S3 credentials.');
12
12
  }
13
13
  const region = context.getNodeParameter('region', 0);
14
14
  const endpoint = context.getNodeParameter('endpoint', 0);
15
15
  const forcePathStyle = context.getNodeParameter('forcePathStyle', 0);
16
- // Extract credentials - handle both direct access and data wrapper
17
- const creds = (credentials.data || credentials);
18
- // Support multiple field naming conventions
19
- const accessKeyId = creds.accessKeyId || creds.access_key_id;
20
- const secretAccessKey = creds.secretAccessKey || creds.secret_access_key;
16
+ // Extract credentials from S3 API credential
17
+ const creds = credentials;
18
+ const accessKeyId = creds.accessKeyId || '';
19
+ const secretAccessKey = creds.secretAccessKey || '';
20
+ const credentialEndpoint = creds.endpoint;
21
+ const credentialRegion = creds.region;
22
+ // Convert forcePathStyle from credential (could be string or boolean)
23
+ const credentialForcePathStyle = String(creds.forcePathStyle) === 'true';
24
+ // Use credential values if node parameters are empty
25
+ const finalEndpoint = endpoint || credentialEndpoint;
26
+ const finalRegion = region || credentialRegion || 'us-east-1';
27
+ // Use boolean OR to combine forcePathStyle from node and credential
28
+ const finalForcePathStyle = forcePathStyle || credentialForcePathStyle || false;
21
29
  if (!accessKeyId || !secretAccessKey) {
22
30
  throw new Error('Invalid credentials. Missing access key or secret key.');
23
31
  }
24
32
  // Auto-determine if path style should be forced
25
- let shouldForcePathStyle = forcePathStyle;
33
+ let shouldForcePathStyle = finalForcePathStyle;
26
34
  // Force path style by default if custom endpoint is provided
27
35
  // This is needed for MinIO, Wasabi, DigitalOcean Spaces, Alibaba OSS, Tencent COS, etc.
28
- if (endpoint && endpoint !== '') {
36
+ if (finalEndpoint && finalEndpoint !== '' && !finalForcePathStyle) {
29
37
  shouldForcePathStyle = true;
30
38
  }
31
39
  const config = {
32
40
  accessKeyId: accessKeyId,
33
41
  secretAccessKey: secretAccessKey,
34
- region: region || 'us-east-1',
42
+ region: finalRegion,
35
43
  bucket,
36
- endpoint: endpoint || undefined,
44
+ endpoint: finalEndpoint || undefined,
37
45
  forcePathStyle: shouldForcePathStyle,
38
46
  };
39
47
  return new S3Storage_1.S3Storage(config);
@@ -50,7 +50,7 @@ class BinaryToUrl {
50
50
  outputs: ['main'],
51
51
  credentials: [
52
52
  {
53
- name: 's3StorageApi',
53
+ name: 's3Api',
54
54
  required: true,
55
55
  },
56
56
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-binary-to-url",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "n8n community node for binary file to public URL bridge with S3 storage",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -40,7 +40,7 @@
40
40
  "n8nNodesApiVersion": 1,
41
41
  "strict": true,
42
42
  "credentials": [
43
- "dist/credentials/S3StorageApi.credentials.js"
43
+ "dist/credentials/S3Api.credentials.js"
44
44
  ],
45
45
  "nodes": [
46
46
  "dist/nodes/BinaryToUrl/BinaryToUrl.node.js"
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.S3StorageApi = void 0;
4
- class S3StorageApi {
5
- constructor() {
6
- this.name = 's3StorageApi';
7
- this.displayName = 'S3 Storage API';
8
- this.icon = 'file:../icons/BinaryToUrl.svg';
9
- this.documentationUrl = 'https://docs.aws.amazon.com/AmazonS3/latest/userguide/AccessCredentials.html';
10
- this.properties = [
11
- {
12
- displayName: 'Access Key ID',
13
- name: 'accessKeyId',
14
- type: 'string',
15
- typeOptions: { password: true },
16
- default: '',
17
- },
18
- {
19
- displayName: 'Secret Access Key',
20
- name: 'secretAccessKey',
21
- type: 'string',
22
- typeOptions: { password: true },
23
- default: '',
24
- },
25
- ];
26
- this.test = {
27
- request: {
28
- baseURL: '={{$credentials.endpoint}}',
29
- url: '=/',
30
- method: 'GET',
31
- },
32
- };
33
- }
34
- }
35
- exports.S3StorageApi = S3StorageApi;