n8n-nodes-binary-to-url 0.0.2 → 0.0.4
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.
package/dist/drivers/index.d.ts
CHANGED
|
@@ -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,
|
|
15
|
+
export declare function createStorageDriver(context: IExecuteFunctions | IWebhookFunctions, bucket: string): Promise<StorageDriver>;
|
package/dist/drivers/index.js
CHANGED
|
@@ -5,24 +5,36 @@ 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,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
throw new Error('AWS S3 credentials are required');
|
|
13
|
-
}
|
|
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);
|
|
8
|
+
async function createStorageDriver(context, bucket) {
|
|
9
|
+
const credentials = await context.getCredentials('awsS3');
|
|
10
|
+
if (!credentials) {
|
|
11
|
+
throw new Error('No S3 credentials found. Please configure S3 credentials.');
|
|
26
12
|
}
|
|
27
|
-
|
|
13
|
+
const region = context.getNodeParameter('region', 0);
|
|
14
|
+
const endpoint = context.getNodeParameter('endpoint', 0);
|
|
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;
|
|
21
|
+
if (!accessKeyId || !secretAccessKey) {
|
|
22
|
+
throw new Error('Invalid credentials. Missing access key or secret key.');
|
|
23
|
+
}
|
|
24
|
+
// Auto-determine if path style should be forced
|
|
25
|
+
let shouldForcePathStyle = forcePathStyle;
|
|
26
|
+
// Force path style by default if custom endpoint is provided
|
|
27
|
+
// This is needed for MinIO, Wasabi, DigitalOcean Spaces, Alibaba OSS, Tencent COS, etc.
|
|
28
|
+
if (endpoint && endpoint !== '') {
|
|
29
|
+
shouldForcePathStyle = true;
|
|
30
|
+
}
|
|
31
|
+
const config = {
|
|
32
|
+
accessKeyId: accessKeyId,
|
|
33
|
+
secretAccessKey: secretAccessKey,
|
|
34
|
+
region: region || 'us-east-1',
|
|
35
|
+
bucket,
|
|
36
|
+
endpoint: endpoint || undefined,
|
|
37
|
+
forcePathStyle: shouldForcePathStyle,
|
|
38
|
+
};
|
|
39
|
+
return new S3Storage_1.S3Storage(config);
|
|
28
40
|
}
|
|
@@ -36,22 +36,21 @@ const ALLOWED_MIME_TYPES = [
|
|
|
36
36
|
class BinaryBridge {
|
|
37
37
|
constructor() {
|
|
38
38
|
this.description = {
|
|
39
|
-
displayName: 'Binary
|
|
40
|
-
name: '
|
|
39
|
+
displayName: 'Binary to URL',
|
|
40
|
+
name: 'binaryToUrl',
|
|
41
41
|
icon: 'file:BinaryBridge.svg',
|
|
42
42
|
group: ['transform'],
|
|
43
43
|
version: 1,
|
|
44
44
|
subtitle: '={{$parameter["operation"]}}',
|
|
45
45
|
description: 'Upload binary files to S3 storage and proxy them via public URL',
|
|
46
46
|
defaults: {
|
|
47
|
-
name: 'Binary
|
|
47
|
+
name: 'Binary to URL',
|
|
48
48
|
},
|
|
49
49
|
inputs: ['main'],
|
|
50
50
|
outputs: ['main'],
|
|
51
51
|
credentials: [
|
|
52
52
|
{
|
|
53
|
-
name: '
|
|
54
|
-
displayName: 'AWS S3 Credentials',
|
|
53
|
+
name: 'awsS3',
|
|
55
54
|
required: true,
|
|
56
55
|
},
|
|
57
56
|
],
|
|
@@ -65,20 +64,6 @@ class BinaryBridge {
|
|
|
65
64
|
},
|
|
66
65
|
],
|
|
67
66
|
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
67
|
{
|
|
83
68
|
displayName: 'Operation',
|
|
84
69
|
name: 'operation',
|
|
@@ -138,36 +123,26 @@ class BinaryBridge {
|
|
|
138
123
|
type: 'string',
|
|
139
124
|
default: 'us-east-1',
|
|
140
125
|
required: true,
|
|
141
|
-
|
|
142
|
-
show: {
|
|
143
|
-
storageDriver: ['s3'],
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
description: 'AWS region',
|
|
126
|
+
description: 'AWS region (leave empty for some S3-compatible services)',
|
|
147
127
|
},
|
|
148
128
|
{
|
|
149
129
|
displayName: 'Custom Endpoint',
|
|
150
130
|
name: 'endpoint',
|
|
151
131
|
type: 'string',
|
|
152
132
|
default: '',
|
|
133
|
+
description: 'Custom S3 endpoint URL (required for MinIO, DigitalOcean Spaces, Wasabi, etc.)',
|
|
153
134
|
displayOptions: {
|
|
154
135
|
show: {
|
|
155
|
-
|
|
136
|
+
operation: ['upload', 'delete'],
|
|
156
137
|
},
|
|
157
138
|
},
|
|
158
|
-
description: 'Custom S3 endpoint URL (for S3-compatible services like Alibaba OSS, Tencent COS, MinIO, etc.)',
|
|
159
139
|
},
|
|
160
140
|
{
|
|
161
141
|
displayName: 'Force Path Style',
|
|
162
142
|
name: 'forcePathStyle',
|
|
163
143
|
type: 'boolean',
|
|
164
144
|
default: false,
|
|
165
|
-
|
|
166
|
-
show: {
|
|
167
|
-
storageDriver: ['s3'],
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
description: 'Use path-style addressing (for MinIO, DigitalOcean Spaces, etc.)',
|
|
145
|
+
description: 'Use path-style addressing (required for MinIO, DigitalOcean Spaces, etc.)',
|
|
171
146
|
},
|
|
172
147
|
],
|
|
173
148
|
};
|
|
@@ -175,13 +150,12 @@ class BinaryBridge {
|
|
|
175
150
|
async execute() {
|
|
176
151
|
const items = this.getInputData();
|
|
177
152
|
const operation = this.getNodeParameter('operation', 0);
|
|
178
|
-
const storageDriver = this.getNodeParameter('storageDriver', 0);
|
|
179
153
|
const bucket = this.getNodeParameter('bucket', 0);
|
|
180
154
|
if (!bucket) {
|
|
181
155
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Bucket name is required');
|
|
182
156
|
}
|
|
183
157
|
try {
|
|
184
|
-
const storage = await (0, drivers_1.createStorageDriver)(this,
|
|
158
|
+
const storage = await (0, drivers_1.createStorageDriver)(this, bucket);
|
|
185
159
|
if (operation === 'upload') {
|
|
186
160
|
return handleUpload(this, items, storage);
|
|
187
161
|
}
|
|
@@ -234,10 +208,9 @@ class BinaryBridge {
|
|
|
234
208
|
},
|
|
235
209
|
};
|
|
236
210
|
}
|
|
237
|
-
const storageDriver = this.getNodeParameter('storageDriver', 0);
|
|
238
211
|
let storage;
|
|
239
212
|
try {
|
|
240
|
-
storage = await (0, drivers_1.createStorageDriver)(this,
|
|
213
|
+
storage = await (0, drivers_1.createStorageDriver)(this, bucket);
|
|
241
214
|
}
|
|
242
215
|
catch (error) {
|
|
243
216
|
return {
|
|
@@ -42,22 +42,21 @@ const ALLOWED_MIME_TYPES = [
|
|
|
42
42
|
|
|
43
43
|
export class BinaryBridge implements INodeType {
|
|
44
44
|
description: INodeTypeDescription = {
|
|
45
|
-
displayName: 'Binary
|
|
46
|
-
name: '
|
|
45
|
+
displayName: 'Binary to URL',
|
|
46
|
+
name: 'binaryToUrl',
|
|
47
47
|
icon: 'file:BinaryBridge.svg',
|
|
48
48
|
group: ['transform'],
|
|
49
49
|
version: 1,
|
|
50
50
|
subtitle: '={{$parameter["operation"]}}',
|
|
51
51
|
description: 'Upload binary files to S3 storage and proxy them via public URL',
|
|
52
52
|
defaults: {
|
|
53
|
-
name: 'Binary
|
|
53
|
+
name: 'Binary to URL',
|
|
54
54
|
},
|
|
55
55
|
inputs: ['main'],
|
|
56
56
|
outputs: ['main'],
|
|
57
57
|
credentials: [
|
|
58
58
|
{
|
|
59
|
-
name: '
|
|
60
|
-
displayName: 'AWS S3 Credentials',
|
|
59
|
+
name: 'awsS3',
|
|
61
60
|
required: true,
|
|
62
61
|
},
|
|
63
62
|
],
|
|
@@ -71,21 +70,6 @@ export class BinaryBridge implements INodeType {
|
|
|
71
70
|
},
|
|
72
71
|
],
|
|
73
72
|
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
73
|
{
|
|
90
74
|
displayName: 'Operation',
|
|
91
75
|
name: 'operation',
|
|
@@ -145,37 +129,27 @@ export class BinaryBridge implements INodeType {
|
|
|
145
129
|
type: 'string',
|
|
146
130
|
default: 'us-east-1',
|
|
147
131
|
required: true,
|
|
148
|
-
|
|
149
|
-
show: {
|
|
150
|
-
storageDriver: ['s3'],
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
description: 'AWS region',
|
|
132
|
+
description: 'AWS region (leave empty for some S3-compatible services)',
|
|
154
133
|
},
|
|
155
134
|
{
|
|
156
135
|
displayName: 'Custom Endpoint',
|
|
157
136
|
name: 'endpoint',
|
|
158
137
|
type: 'string',
|
|
159
138
|
default: '',
|
|
139
|
+
description:
|
|
140
|
+
'Custom S3 endpoint URL (required for MinIO, DigitalOcean Spaces, Wasabi, etc.)',
|
|
160
141
|
displayOptions: {
|
|
161
142
|
show: {
|
|
162
|
-
|
|
143
|
+
operation: ['upload', 'delete'],
|
|
163
144
|
},
|
|
164
145
|
},
|
|
165
|
-
description:
|
|
166
|
-
'Custom S3 endpoint URL (for S3-compatible services like Alibaba OSS, Tencent COS, MinIO, etc.)',
|
|
167
146
|
},
|
|
168
147
|
{
|
|
169
148
|
displayName: 'Force Path Style',
|
|
170
149
|
name: 'forcePathStyle',
|
|
171
150
|
type: 'boolean',
|
|
172
151
|
default: false,
|
|
173
|
-
|
|
174
|
-
show: {
|
|
175
|
-
storageDriver: ['s3'],
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
description: 'Use path-style addressing (for MinIO, DigitalOcean Spaces, etc.)',
|
|
152
|
+
description: 'Use path-style addressing (required for MinIO, DigitalOcean Spaces, etc.)',
|
|
179
153
|
},
|
|
180
154
|
],
|
|
181
155
|
};
|
|
@@ -183,7 +157,6 @@ export class BinaryBridge implements INodeType {
|
|
|
183
157
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
184
158
|
const items = this.getInputData();
|
|
185
159
|
const operation = this.getNodeParameter('operation', 0) as string;
|
|
186
|
-
const storageDriver = this.getNodeParameter('storageDriver', 0) as string;
|
|
187
160
|
const bucket = this.getNodeParameter('bucket', 0) as string;
|
|
188
161
|
|
|
189
162
|
if (!bucket) {
|
|
@@ -191,7 +164,7 @@ export class BinaryBridge implements INodeType {
|
|
|
191
164
|
}
|
|
192
165
|
|
|
193
166
|
try {
|
|
194
|
-
const storage = await createStorageDriver(this,
|
|
167
|
+
const storage = await createStorageDriver(this, bucket);
|
|
195
168
|
|
|
196
169
|
if (operation === 'upload') {
|
|
197
170
|
return handleUpload(this, items, storage);
|
|
@@ -250,10 +223,9 @@ export class BinaryBridge implements INodeType {
|
|
|
250
223
|
};
|
|
251
224
|
}
|
|
252
225
|
|
|
253
|
-
const storageDriver = this.getNodeParameter('storageDriver', 0) as string;
|
|
254
226
|
let storage;
|
|
255
227
|
try {
|
|
256
|
-
storage = await createStorageDriver(this,
|
|
228
|
+
storage = await createStorageDriver(this, bucket);
|
|
257
229
|
} catch (error) {
|
|
258
230
|
return {
|
|
259
231
|
webhookResponse: {
|
|
@@ -42,22 +42,21 @@ const ALLOWED_MIME_TYPES = [
|
|
|
42
42
|
|
|
43
43
|
export class BinaryBridge implements INodeType {
|
|
44
44
|
description: INodeTypeDescription = {
|
|
45
|
-
displayName: 'Binary
|
|
46
|
-
name: '
|
|
45
|
+
displayName: 'Binary to URL',
|
|
46
|
+
name: 'binaryToUrl',
|
|
47
47
|
icon: 'file:BinaryBridge.svg',
|
|
48
48
|
group: ['transform'],
|
|
49
49
|
version: 1,
|
|
50
50
|
subtitle: '={{$parameter["operation"]}}',
|
|
51
51
|
description: 'Upload binary files to S3 storage and proxy them via public URL',
|
|
52
52
|
defaults: {
|
|
53
|
-
name: 'Binary
|
|
53
|
+
name: 'Binary to URL',
|
|
54
54
|
},
|
|
55
55
|
inputs: ['main'],
|
|
56
56
|
outputs: ['main'],
|
|
57
57
|
credentials: [
|
|
58
58
|
{
|
|
59
|
-
name: '
|
|
60
|
-
displayName: 'AWS S3 Credentials',
|
|
59
|
+
name: 'awsS3',
|
|
61
60
|
required: true,
|
|
62
61
|
},
|
|
63
62
|
],
|
|
@@ -71,21 +70,6 @@ export class BinaryBridge implements INodeType {
|
|
|
71
70
|
},
|
|
72
71
|
],
|
|
73
72
|
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
73
|
{
|
|
90
74
|
displayName: 'Operation',
|
|
91
75
|
name: 'operation',
|
|
@@ -145,37 +129,27 @@ export class BinaryBridge implements INodeType {
|
|
|
145
129
|
type: 'string',
|
|
146
130
|
default: 'us-east-1',
|
|
147
131
|
required: true,
|
|
148
|
-
|
|
149
|
-
show: {
|
|
150
|
-
storageDriver: ['s3'],
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
description: 'AWS region',
|
|
132
|
+
description: 'AWS region (leave empty for some S3-compatible services)',
|
|
154
133
|
},
|
|
155
134
|
{
|
|
156
135
|
displayName: 'Custom Endpoint',
|
|
157
136
|
name: 'endpoint',
|
|
158
137
|
type: 'string',
|
|
159
138
|
default: '',
|
|
139
|
+
description:
|
|
140
|
+
'Custom S3 endpoint URL (required for MinIO, DigitalOcean Spaces, Wasabi, etc.)',
|
|
160
141
|
displayOptions: {
|
|
161
142
|
show: {
|
|
162
|
-
|
|
143
|
+
operation: ['upload', 'delete'],
|
|
163
144
|
},
|
|
164
145
|
},
|
|
165
|
-
description:
|
|
166
|
-
'Custom S3 endpoint URL (for S3-compatible services like Alibaba OSS, Tencent COS, MinIO, etc.)',
|
|
167
146
|
},
|
|
168
147
|
{
|
|
169
148
|
displayName: 'Force Path Style',
|
|
170
149
|
name: 'forcePathStyle',
|
|
171
150
|
type: 'boolean',
|
|
172
151
|
default: false,
|
|
173
|
-
|
|
174
|
-
show: {
|
|
175
|
-
storageDriver: ['s3'],
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
description: 'Use path-style addressing (for MinIO, DigitalOcean Spaces, etc.)',
|
|
152
|
+
description: 'Use path-style addressing (required for MinIO, DigitalOcean Spaces, etc.)',
|
|
179
153
|
},
|
|
180
154
|
],
|
|
181
155
|
};
|
|
@@ -183,7 +157,6 @@ export class BinaryBridge implements INodeType {
|
|
|
183
157
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
184
158
|
const items = this.getInputData();
|
|
185
159
|
const operation = this.getNodeParameter('operation', 0) as string;
|
|
186
|
-
const storageDriver = this.getNodeParameter('storageDriver', 0) as string;
|
|
187
160
|
const bucket = this.getNodeParameter('bucket', 0) as string;
|
|
188
161
|
|
|
189
162
|
if (!bucket) {
|
|
@@ -191,7 +164,7 @@ export class BinaryBridge implements INodeType {
|
|
|
191
164
|
}
|
|
192
165
|
|
|
193
166
|
try {
|
|
194
|
-
const storage = await createStorageDriver(this,
|
|
167
|
+
const storage = await createStorageDriver(this, bucket);
|
|
195
168
|
|
|
196
169
|
if (operation === 'upload') {
|
|
197
170
|
return handleUpload(this, items, storage);
|
|
@@ -250,10 +223,9 @@ export class BinaryBridge implements INodeType {
|
|
|
250
223
|
};
|
|
251
224
|
}
|
|
252
225
|
|
|
253
|
-
const storageDriver = this.getNodeParameter('storageDriver', 0) as string;
|
|
254
226
|
let storage;
|
|
255
227
|
try {
|
|
256
|
-
storage = await createStorageDriver(this,
|
|
228
|
+
storage = await createStorageDriver(this, bucket);
|
|
257
229
|
} catch (error) {
|
|
258
230
|
return {
|
|
259
231
|
webhookResponse: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-binary-to-url",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
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
|
}
|