-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: start version 3 * feat: Use ES modules (#727) * feat: Url search params and remove multiple (#730) * docs: Fixed the missing "=" in options.filter (#732) * docs: fix example * docs: specify what part actually is * docs: fix types * docs: add warning for progress event * docs: finish removing multiples in examples * docs: add example for express as middleware * docs: example handle common internet errors * feat: add corepack support * fix: corepack support * fix: fix examples comment * fix: fix example comment * feat: add firstValues, readBooleans helpers (#757) * feat: add firstValues, readBooleans helpers * feat: export types * docs: document helpers * docs: fix example * fix: #760 (#761) * fix: fix error when there is an error * tests: fix some of the tests (#763) * chore: up supertest jest and nyc * tests: convert to import , fix some tests * test: make malformed boundary as per comment ? * tests: refactor * style: fix some prettier issues (#764) * chore: publish as 3.x tag * docs: add changelog link * docs: typo Co-authored-by: Hrushikesh Das <dashrushikesh1121@gmail.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
- Loading branch information
1 parent
1c30ec6
commit 70517da
Showing
57 changed files
with
2,163 additions
and
2,451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import express from 'express'; | ||
import formidable from '../src/index.js'; | ||
|
||
const app = express(); | ||
|
||
// middlewares that populates req.fields and req.body | ||
const formMiddleWare = (req, res, next) => { | ||
const form = formidable({}); | ||
|
||
form.parse(req, (err, fields, files) => { | ||
if (err) { | ||
next(err); | ||
return; | ||
} | ||
req.fields = fields; | ||
req.files = files; | ||
next(); | ||
}); | ||
}; | ||
|
||
app.get('/', (req, res) => { | ||
res.send(` | ||
<h2>With <code>"express"</code> npm package</h2> | ||
<form action="/api/upload" enctype="multipart/form-data" method="post"> | ||
<div>Text field title: <input type="text" name="title" /></div> | ||
<div>File: <input type="file" name="someExpressFiles" multiple="multiple"></div> | ||
<input type="submit" value="Upload"> | ||
</form> | ||
`); | ||
}); | ||
|
||
// use middleware | ||
app.post('/api/upload', formMiddleWare, (req, res, next) => { | ||
res.json({ | ||
fields: req.fields, | ||
files: req.files, | ||
}); | ||
}); | ||
|
||
app.listen(3000, () => { | ||
console.log('Server listening on http://localhost:3000 ...'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.