n8n-nodes-binary-to-url 0.0.2 → 0.0.3

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.
@@ -12,4 +12,4 @@ export interface StorageDriver {
12
12
  }>;
13
13
  deleteFile(fileKey: string): Promise<void>;
14
14
  }
15
- export declare function createStorageDriver(context: IExecuteFunctions | IWebhookFunctions, storageDriver: string, bucket: string): Promise<StorageDriver>;
15
+ export declare function createStorageDriver(context: IExecuteFunctions | IWebhookFunctions, bucket: string): Promise<StorageDriver>;
@@ -5,24 +5,59 @@ exports.createStorageDriver = createStorageDriver;
5
5
  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
- async function createStorageDriver(context, storageDriver, bucket) {
9
- if (storageDriver === 's3') {
10
- const credentials = await context.getCredentials('awsS3Api');
11
- if (!credentials) {
12
- throw new Error('AWS S3 credentials are required');
8
+ async function createStorageDriver(context, bucket) {
9
+ // Try S3 Compatible credentials first (MinIO, Wasabi, DigitalOcean, Alibaba OSS, Tencent COS, etc.)
10
+ let credentials = null;
11
+ let isAwsS3 = false;
12
+ try {
13
+ credentials = await context.getCredentials('awsS3');
14
+ if (credentials) {
15
+ isAwsS3 = false;
13
16
  }
14
- const region = context.getNodeParameter('region', 0);
15
- const endpoint = context.getNodeParameter('endpoint', 0);
16
- const forcePathStyle = context.getNodeParameter('forcePathStyle', 0);
17
- const config = {
18
- accessKeyId: credentials.accessKeyId,
19
- secretAccessKey: credentials.secretAccessKey,
20
- region,
21
- bucket,
22
- endpoint: endpoint || undefined,
23
- forcePathStyle,
24
- };
25
- return new S3Storage_1.S3Storage(config);
26
17
  }
27
- throw new Error(`Unknown storage driver: ${storageDriver}`);
18
+ catch (error) {
19
+ // S3 Compatible credentials not found, try AWS S3
20
+ }
21
+ // If S3 Compatible credentials not found, try AWS S3 API credentials
22
+ if (!credentials) {
23
+ try {
24
+ credentials = await context.getCredentials('awsS3Api');
25
+ if (credentials) {
26
+ isAwsS3 = true;
27
+ }
28
+ }
29
+ catch (error) {
30
+ // AWS S3 credentials not found
31
+ }
32
+ }
33
+ if (!credentials) {
34
+ throw new Error('No S3 credentials found. Please configure either "S3 Compatible" or "AWS S3" credentials.');
35
+ }
36
+ const region = context.getNodeParameter('region', 0);
37
+ const endpoint = context.getNodeParameter('endpoint', 0);
38
+ const forcePathStyle = context.getNodeParameter('forcePathStyle', 0);
39
+ // Extract credentials - different credential types may use different field names
40
+ const accessKeyId = credentials.accessKeyId || credentials.access_key_id;
41
+ const secretAccessKey = credentials.secretAccessKey || credentials.secret_access_key || credentials.secret_access_key;
42
+ if (!accessKeyId || !secretAccessKey) {
43
+ throw new Error('Invalid credentials. Missing access key or secret key.');
44
+ }
45
+ // Auto-determine if path style should be forced
46
+ let shouldForcePathStyle = forcePathStyle;
47
+ // For S3 Compatible services (awsS3), force path style by default if endpoint is provided
48
+ // This is needed for MinIO, Wasabi, DigitalOcean Spaces, Alibaba OSS, Tencent COS, etc.
49
+ if (!isAwsS3) {
50
+ if (endpoint && endpoint !== '') {
51
+ shouldForcePathStyle = true;
52
+ }
53
+ }
54
+ const config = {
55
+ accessKeyId: accessKeyId,
56
+ secretAccessKey: secretAccessKey,
57
+ region: region || 'us-east-1',
58
+ bucket,
59
+ endpoint: endpoint || undefined,
60
+ forcePathStyle: shouldForcePathStyle,
61
+ };
62
+ return new S3Storage_1.S3Storage(config);
28
63
  }
@@ -49,9 +49,14 @@ class BinaryBridge {
49
49
  inputs: ['main'],
50
50
  outputs: ['main'],
51
51
  credentials: [
52
+ {
53
+ name: 'awsS3',
54
+ displayName: 'S3 Compatible',
55
+ required: true,
56
+ },
52
57
  {
53
58
  name: 'awsS3Api',
54
- displayName: 'AWS S3 Credentials',
59
+ displayName: 'AWS S3',
55
60
  required: true,
56
61
  },
57
62
  ],
@@ -65,20 +70,6 @@ class BinaryBridge {
65
70
  },
66
71
  ],
67
72
  properties: [
68
- {
69
- displayName: 'Storage Driver',
70
- name: 'storageDriver',
71
- type: 'options',
72
- noDataExpression: true,
73
- options: [
74
- {
75
- name: 'AWS S3',
76
- value: 's3',
77
- description: 'Use AWS S3 or S3-compatible storage (Alibaba OSS, Tencent COS, MinIO, etc.)',
78
- },
79
- ],
80
- default: 's3',
81
- },
82
73
  {
83
74
  displayName: 'Operation',
84
75
  name: 'operation',
@@ -138,36 +129,26 @@ class BinaryBridge {
138
129
  type: 'string',
139
130
  default: 'us-east-1',
140
131
  required: true,
141
- displayOptions: {
142
- show: {
143
- storageDriver: ['s3'],
144
- },
145
- },
146
- description: 'AWS region',
132
+ description: 'AWS region (leave empty for some S3-compatible services)',
147
133
  },
148
134
  {
149
135
  displayName: 'Custom Endpoint',
150
136
  name: 'endpoint',
151
137
  type: 'string',
152
138
  default: '',
139
+ description: 'Custom S3 endpoint URL (required for MinIO, DigitalOcean Spaces, Wasabi, etc.)',
153
140
  displayOptions: {
154
141
  show: {
155
- storageDriver: ['s3'],
142
+ operation: ['upload', 'delete'],
156
143
  },
157
144
  },
158
- description: 'Custom S3 endpoint URL (for S3-compatible services like Alibaba OSS, Tencent COS, MinIO, etc.)',
159
145
  },
160
146
  {
161
147
  displayName: 'Force Path Style',
162
148
  name: 'forcePathStyle',
163
149
  type: 'boolean',
164
150
  default: false,
165
- displayOptions: {
166
- show: {
167
- storageDriver: ['s3'],
168
- },
169
- },
170
- description: 'Use path-style addressing (for MinIO, DigitalOcean Spaces, etc.)',
151
+ description: 'Use path-style addressing (required for MinIO, DigitalOcean Spaces, etc.)',
171
152
  },
172
153
  ],
173
154
  };
@@ -175,13 +156,12 @@ class BinaryBridge {
175
156
  async execute() {
176
157
  const items = this.getInputData();
177
158
  const operation = this.getNodeParameter('operation', 0);
178
- const storageDriver = this.getNodeParameter('storageDriver', 0);
179
159
  const bucket = this.getNodeParameter('bucket', 0);
180
160
  if (!bucket) {
181
161
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Bucket name is required');
182
162
  }
183
163
  try {
184
- const storage = await (0, drivers_1.createStorageDriver)(this, storageDriver, bucket);
164
+ const storage = await (0, drivers_1.createStorageDriver)(this, bucket);
185
165
  if (operation === 'upload') {
186
166
  return handleUpload(this, items, storage);
187
167
  }
@@ -234,10 +214,9 @@ class BinaryBridge {
234
214
  },
235
215
  };
236
216
  }
237
- const storageDriver = this.getNodeParameter('storageDriver', 0);
238
217
  let storage;
239
218
  try {
240
- storage = await (0, drivers_1.createStorageDriver)(this, storageDriver, bucket);
219
+ storage = await (0, drivers_1.createStorageDriver)(this, bucket);
241
220
  }
242
221
  catch (error) {
243
222
  return {
@@ -55,9 +55,14 @@ export class BinaryBridge implements INodeType {
55
55
  inputs: ['main'],
56
56
  outputs: ['main'],
57
57
  credentials: [
58
+ {
59
+ name: 'awsS3',
60
+ displayName: 'S3 Compatible',
61
+ required: true,
62
+ },
58
63
  {
59
64
  name: 'awsS3Api',
60
- displayName: 'AWS S3 Credentials',
65
+ displayName: 'AWS S3',
61
66
  required: true,
62
67
  },
63
68
  ],
@@ -71,21 +76,6 @@ export class BinaryBridge implements INodeType {
71
76
  },
72
77
  ],
73
78
  properties: [
74
- {
75
- displayName: 'Storage Driver',
76
- name: 'storageDriver',
77
- type: 'options',
78
- noDataExpression: true,
79
- options: [
80
- {
81
- name: 'AWS S3',
82
- value: 's3',
83
- description:
84
- 'Use AWS S3 or S3-compatible storage (Alibaba OSS, Tencent COS, MinIO, etc.)',
85
- },
86
- ],
87
- default: 's3',
88
- },
89
79
  {
90
80
  displayName: 'Operation',
91
81
  name: 'operation',
@@ -145,37 +135,27 @@ export class BinaryBridge implements INodeType {
145
135
  type: 'string',
146
136
  default: 'us-east-1',
147
137
  required: true,
148
- displayOptions: {
149
- show: {
150
- storageDriver: ['s3'],
151
- },
152
- },
153
- description: 'AWS region',
138
+ description: 'AWS region (leave empty for some S3-compatible services)',
154
139
  },
155
140
  {
156
141
  displayName: 'Custom Endpoint',
157
142
  name: 'endpoint',
158
143
  type: 'string',
159
144
  default: '',
145
+ description:
146
+ 'Custom S3 endpoint URL (required for MinIO, DigitalOcean Spaces, Wasabi, etc.)',
160
147
  displayOptions: {
161
148
  show: {
162
- storageDriver: ['s3'],
149
+ operation: ['upload', 'delete'],
163
150
  },
164
151
  },
165
- description:
166
- 'Custom S3 endpoint URL (for S3-compatible services like Alibaba OSS, Tencent COS, MinIO, etc.)',
167
152
  },
168
153
  {
169
154
  displayName: 'Force Path Style',
170
155
  name: 'forcePathStyle',
171
156
  type: 'boolean',
172
157
  default: false,
173
- displayOptions: {
174
- show: {
175
- storageDriver: ['s3'],
176
- },
177
- },
178
- description: 'Use path-style addressing (for MinIO, DigitalOcean Spaces, etc.)',
158
+ description: 'Use path-style addressing (required for MinIO, DigitalOcean Spaces, etc.)',
179
159
  },
180
160
  ],
181
161
  };
@@ -183,7 +163,6 @@ export class BinaryBridge implements INodeType {
183
163
  async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
184
164
  const items = this.getInputData();
185
165
  const operation = this.getNodeParameter('operation', 0) as string;
186
- const storageDriver = this.getNodeParameter('storageDriver', 0) as string;
187
166
  const bucket = this.getNodeParameter('bucket', 0) as string;
188
167
 
189
168
  if (!bucket) {
@@ -191,7 +170,7 @@ export class BinaryBridge implements INodeType {
191
170
  }
192
171
 
193
172
  try {
194
- const storage = await createStorageDriver(this, storageDriver, bucket);
173
+ const storage = await createStorageDriver(this, bucket);
195
174
 
196
175
  if (operation === 'upload') {
197
176
  return handleUpload(this, items, storage);
@@ -250,10 +229,9 @@ export class BinaryBridge implements INodeType {
250
229
  };
251
230
  }
252
231
 
253
- const storageDriver = this.getNodeParameter('storageDriver', 0) as string;
254
232
  let storage;
255
233
  try {
256
- storage = await createStorageDriver(this, storageDriver, bucket);
234
+ storage = await createStorageDriver(this, bucket);
257
235
  } catch (error) {
258
236
  return {
259
237
  webhookResponse: {
@@ -55,9 +55,14 @@ export class BinaryBridge implements INodeType {
55
55
  inputs: ['main'],
56
56
  outputs: ['main'],
57
57
  credentials: [
58
+ {
59
+ name: 'awsS3',
60
+ displayName: 'S3 Compatible',
61
+ required: true,
62
+ },
58
63
  {
59
64
  name: 'awsS3Api',
60
- displayName: 'AWS S3 Credentials',
65
+ displayName: 'AWS S3',
61
66
  required: true,
62
67
  },
63
68
  ],
@@ -71,21 +76,6 @@ export class BinaryBridge implements INodeType {
71
76
  },
72
77
  ],
73
78
  properties: [
74
- {
75
- displayName: 'Storage Driver',
76
- name: 'storageDriver',
77
- type: 'options',
78
- noDataExpression: true,
79
- options: [
80
- {
81
- name: 'AWS S3',
82
- value: 's3',
83
- description:
84
- 'Use AWS S3 or S3-compatible storage (Alibaba OSS, Tencent COS, MinIO, etc.)',
85
- },
86
- ],
87
- default: 's3',
88
- },
89
79
  {
90
80
  displayName: 'Operation',
91
81
  name: 'operation',
@@ -145,37 +135,27 @@ export class BinaryBridge implements INodeType {
145
135
  type: 'string',
146
136
  default: 'us-east-1',
147
137
  required: true,
148
- displayOptions: {
149
- show: {
150
- storageDriver: ['s3'],
151
- },
152
- },
153
- description: 'AWS region',
138
+ description: 'AWS region (leave empty for some S3-compatible services)',
154
139
  },
155
140
  {
156
141
  displayName: 'Custom Endpoint',
157
142
  name: 'endpoint',
158
143
  type: 'string',
159
144
  default: '',
145
+ description:
146
+ 'Custom S3 endpoint URL (required for MinIO, DigitalOcean Spaces, Wasabi, etc.)',
160
147
  displayOptions: {
161
148
  show: {
162
- storageDriver: ['s3'],
149
+ operation: ['upload', 'delete'],
163
150
  },
164
151
  },
165
- description:
166
- 'Custom S3 endpoint URL (for S3-compatible services like Alibaba OSS, Tencent COS, MinIO, etc.)',
167
152
  },
168
153
  {
169
154
  displayName: 'Force Path Style',
170
155
  name: 'forcePathStyle',
171
156
  type: 'boolean',
172
157
  default: false,
173
- displayOptions: {
174
- show: {
175
- storageDriver: ['s3'],
176
- },
177
- },
178
- description: 'Use path-style addressing (for MinIO, DigitalOcean Spaces, etc.)',
158
+ description: 'Use path-style addressing (required for MinIO, DigitalOcean Spaces, etc.)',
179
159
  },
180
160
  ],
181
161
  };
@@ -183,7 +163,6 @@ export class BinaryBridge implements INodeType {
183
163
  async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
184
164
  const items = this.getInputData();
185
165
  const operation = this.getNodeParameter('operation', 0) as string;
186
- const storageDriver = this.getNodeParameter('storageDriver', 0) as string;
187
166
  const bucket = this.getNodeParameter('bucket', 0) as string;
188
167
 
189
168
  if (!bucket) {
@@ -191,7 +170,7 @@ export class BinaryBridge implements INodeType {
191
170
  }
192
171
 
193
172
  try {
194
- const storage = await createStorageDriver(this, storageDriver, bucket);
173
+ const storage = await createStorageDriver(this, bucket);
195
174
 
196
175
  if (operation === 'upload') {
197
176
  return handleUpload(this, items, storage);
@@ -250,10 +229,9 @@ export class BinaryBridge implements INodeType {
250
229
  };
251
230
  }
252
231
 
253
- const storageDriver = this.getNodeParameter('storageDriver', 0) as string;
254
232
  let storage;
255
233
  try {
256
- storage = await createStorageDriver(this, storageDriver, bucket);
234
+ storage = await createStorageDriver(this, bucket);
257
235
  } catch (error) {
258
236
  return {
259
237
  webhookResponse: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-binary-to-url",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
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",
@@ -58,5 +58,8 @@
58
58
  },
59
59
  "peerDependencies": {
60
60
  "n8n-workflow": "*"
61
+ },
62
+ "publishConfig": {
63
+ "registry": "https://registry.npmjs.org"
61
64
  }
62
65
  }