Closed krusk closed 4 years ago
I'm behind exactly the same use case i still can't find the answer clearly. Have you made some progress on this?
I want to able to parse multipart/related response from xhr in the front-end to inmmediately play an audio file and show some metadata that comes in json from the API.
It looks like formidable can deal with it, but theres a lot of code for file handling, storing, and connecting / integrating the with node servers that generates errors when trying to use it clientside in a browser.
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
The example is now at https://github.com/node-formidable/formidable/blob/master/examples/multipart-parser.js
But how do I adapt the code to use it with formidable that I've installed?
Replacing the require with const { MultipartParser } = require('formidable/lib/multipart_parser.js');
results in
multipartParser.on('data', ({ name, buffer, start, end }) => {
^
TypeError: multipartParser.on is not a functio
And it looks like index.js
only exports IncomingForm
. So how do I use the parser standalone?
const { MultipartParser } = require('formidable');
or
const MultipartParser = require('formidable/src/parsers/Multipart.js');
lib does not exist
lib does not exist
I assume it must be created during the publish process
docker run --rm -it node:14 /bin/bash
npm i formidable
cd node_modules/formidable/
ls
# LICENSE README.md benchmark-2020-01-29_xeon-x3440.png lib package.json
ls lib/
# file.js incoming_form.js index.js json_parser.js multipart_parser.js octet_parser.js querystring_parser.js
install from master branch npm i github:node-formidable/formidable
@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!
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:
Is this something that Formidable can manage, and if so, how?
Thanks,
K.