Upload file to another Server Using Node.js

Not applicable

Hi,

I'm receiving the Multipart/form-data request in Node js and sending the file to another server by calling API.

I'm using formidable to handle form data.request to send the file to the server.

I've tried that same process on the local machine using Node.js that wok's well. Here Node js stores the form-data file locally and sends the file to another server.

But in APIGEE form-data file can't be stored temporarily. It's loading and got timed out in that part. It seems Node.js container have access to the store temp file.

I'm attaching my proxy bundle here.

consumerappimageupload-rev2-2018-04-23.zip

Please give me an idea how to proceed.

1 2 8,049
2 REPLIES 2

I don't know formidable, but it looks to me that it by default will parse out files and store them in os.tmpdir() .

You don't want that when hosting nodejs within Apigee /Trireme. The API exposed by formidable allows you to override the onPart function to do your own handling of files. You'd need to capture the file event and parse the stream, maybe hold the file in memory (be careful of large files to protect against DOS) and then upload that memory stream to the remote server.

This answer on stack overflow provides hints.

Another suggestion is to use a different module for parsing the multipart stream, like multiparty. There's an example on the README showing how to handle files without writing them to the filesystem.

Not applicable

I understand you want to use Formidable. However, in the past I've used I've use Multer with Apigee and works like a charm. Take a look and this thread. And lemme know if you have any questions.

https://community.apigee.com/questions/39803/how-to-post-multipart-request-in-apigee.html

Hope it helps!