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

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.
@@ -254,7 +254,12 @@ class BinaryToUrl {
254
254
  exports.BinaryToUrl = BinaryToUrl;
255
255
  async function handleUpload(context, items, storage) {
256
256
  const binaryPropertyName = context.getNodeParameter('binaryPropertyName', 0);
257
- const webhookBaseUrl = buildWebhookUrl(context, 'default', 'file');
257
+ // Build webhook URL using n8n's instance base URL and workflow ID
258
+ // Format: {baseUrl}/webhook/{workflowId}/file/:fileKey
259
+ const baseUrl = context.getInstanceBaseUrl();
260
+ const workflow = context.getWorkflow();
261
+ const workflowId = workflow.id;
262
+ const webhookUrl = `${baseUrl}/webhook/${workflowId}/file/:fileKey`;
258
263
  const returnData = [];
259
264
  for (const item of items) {
260
265
  const binaryData = item.binary?.[binaryPropertyName];
@@ -272,7 +277,8 @@ async function handleUpload(context, items, storage) {
272
277
  throw new n8n_workflow_1.NodeOperationError(context.getNode(), `File size exceeds maximum limit of ${MAX_FILE_SIZE / 1024 / 1024}MB`);
273
278
  }
274
279
  const result = await storage.uploadStream(buffer, contentType);
275
- const proxyUrl = `${webhookBaseUrl}/${result.fileKey}`;
280
+ // Replace the :fileKey placeholder with the actual file key
281
+ const proxyUrl = webhookUrl.replace(':fileKey', result.fileKey);
276
282
  returnData.push({
277
283
  json: {
278
284
  fileKey: result.fileKey,
@@ -302,14 +308,6 @@ async function handleDelete(context, items, storage) {
302
308
  }
303
309
  return [returnData];
304
310
  }
305
- function buildWebhookUrl(context, webhookName, path) {
306
- const baseUrl = context.getInstanceBaseUrl();
307
- const node = context.getNode();
308
- const workflow = context.getWorkflow();
309
- const workflowId = workflow.id;
310
- const nodeName = encodeURIComponent(node.name.toLowerCase());
311
- return `${baseUrl}/webhook/${workflowId}/${nodeName}/${path}`;
312
- }
313
311
  function isValidFileKey(fileKey) {
314
312
  if (!fileKey || typeof fileKey !== 'string') {
315
313
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-binary-to-url",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
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",