How to Handle Multipart/Form-Data File Uploads in Community Nodes?

Hi n8n community,

I’m developing a WoodWing community node that needs to support file uploads via multipart/form-data requests. I’ve run into a challenging situation and would appreciate
guidance.

The Requirement

The WoodWing API requires uploading files using multipart/form-data encoding, which is essential for operations like:

  • Uploading assets/images
  • Importing documents
  • Sending binary data to the API

The Problem

From my research, handling multipart/form-data properly typically requires an external library like form-data. When I examined official n8n nodes (such as the Google Drive
node and others), I can see they use this library successfully.

However, I’ve learned that community nodes intended for cloud hosting cannot use external dependencies/libraries - they must be dependency-free to be approved for the n8n
cloud ecosystem.

The Dilemma

This creates a conflict:

  • Official n8n nodes can use form-data and other libraries
  • Community nodes cannot use external dependencies for cloud compatibility
  • But file upload functionality is essential for many APIs

Questions for the Community

  1. Is there a native n8n way to construct multipart/form-data requests without external libraries?
  2. Should community nodes with essential file upload needs be published as npm packages only (not cloud-compatible)?
  3. Is there a workaround or built-in helper in the n8n SDK that I’m missing?
  4. How do other community node developers handle this limitation when working with APIs that require file uploads?

Why This Matters

The WoodWing node would benefit many users in the digital asset management and publishing space, but without file upload capabilities, it would be incomplete. I suspect
other community developers face similar challenges with various APIs.

Any guidance on the recommended approach would be greatly appreciated!

I have came across this issue when building my node, n8n-nodes-tmpfiles. Ended up building multipart form-data body manually. Here is a snippet:

			const boundary = `----n8nFormBoundary${Date.now()}`;
			const preamble =
				`--${boundary}\r\n` +
				`Content-Disposition: form-data; name="file"; filename="${fileName}"\r\n` +
				`Content-Type: ${mimeType}\r\n\r\n`;
			const closing = `\r\n--${boundary}--\r\n`;
			const bodyBuffer = Buffer.concat([
				Buffer.from(preamble, 'utf8'),
				buffer as unknown as BinaryBuffer,
				Buffer.from(closing, 'utf8'),
			]);

			const requestOptions: IHttpRequestOptions = {
				method: 'POST',
				url: 'https://tmpfiles.org/api/v1/upload',
				headers: {
					'Content-Type': `multipart/form-data; boundary=${boundary}`,
					'Content-Length': bodyBuffer.length,
				},
				body: bodyBuffer,
			};

You can view the full code from npm or GitHub and use it as a template for your node. And yes, all community nodes are required to be released and up-to-date on npm.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.