question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parse multipart file using formidable

See original GitHub issue

Hi all,

I am receiving a multipart file via a REST service call to a vendors API. This file includes XML data and blob data for two images. I need to be able to split and store these as individual files using Node/Express. I have seen a lot posts/resources on multipart form data, but my needs are parsing this using JavaScript into individual files that can then be uploaded into Azure Blob Storage. I suspect Node/Express or a Node module such as request (https://github.com/request/request) would be the right way to go, but haven’t found anything concrete. Here is an example of the multipart file. Note that there is not filename for the multipart file:

MIME-Version:1.0
Content-Type:multipart/mixed; 
boundary="----=_Part_4_153315749.1440434094461"

------=_Part_4_153315749.1440434094461
Content-Type: application/octet-stream; name=Texture_1.png
Content-ID: response-1
Content-Disposition: attachment; filename=Texture_1.png

‰PNG
"blob data here"

------=_Part_4_153315749.1440434094461
Content-Type: application/octet-stream; name=manifest.xml
Content-ID: response-2
Content-Disposition: attachment; filename=manifest.xml

<?xml version="1.0"?>
<dae_root>blank_3D.dae</dae_root>

------=_Part_4_153315749.1440434094461
Content-Type: application/octet-stream; name=texture_3D.dae
Content-ID: response-3
Content-Disposition: attachment; filename=texture_3D.dae

<xml data here... lots of xml data>

------=_Part_4_153315749.1440434094461
Content-Type: application/octet-stream; name=Texture_0.png
Content-ID: response-4
Content-Disposition: attachment; filename=Texture_0.png

‰PNG
"blob image data"

Is this something that Formidable can manage, and if so, how?

Thanks,

K.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
GrosSacASaccommented, Dec 5, 2019

Check this example https://github.com/node-formidable/node-formidable/blob/master/example/multipartParser.js. it shows how to use the multipart parser as standalone

0reactions
Prinzhorncommented, Mar 2, 2021

@GrosSacASac I understand that this is possible and I can also do npm install formidable@canary but I’m under the impression that “canary” means not production?

Edit: But I understand now, the example code is meant to be used with the latest release and I probably have to adjust it for the stable release. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uploading Files using Formidable in a Node.js Application
In this article, we will learn how we can upload files using node.js, express, and formidable. Formidable is a Node.js module for parsing...
Read more >
Formidable: Parse multipart/form-data request THEN upload file
The idea of multer and formidable is to write the file to the uploadDir as the request is being consumed. If you do...
Read more >
Parse multipart file using formidable · Issue #355 - GitHub
Hi all, I am receiving a multipart file via a REST service call to a vendors API. This file includes XML data and...
Read more >
Using formidable to handle file uploads | Node Cookbook
In this recipe, we will use the formidable module as our multipart parser to handle file uploads. Getting ready. First, let's create a...
Read more >
formidable
Fast (~500mb/sec), non-buffering multipart parser · Automatically writing file uploads to disk · Low memory footprint · Graceful error handling · Very high...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found