Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Jul 4, 2019
2 parents 4cd0f6c + 23f930e commit 2373b7e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions README.md
Expand Up @@ -40,6 +40,7 @@ app.use((err, req, res, next) => {
## Example Express API Server

Try the complete example below:
(_it includes file upload as well!_)

```javascript
var express = require('express');
Expand Down Expand Up @@ -82,20 +83,18 @@ app.get('/v1/pets/:id', function(req, res, next) {
res.json({ id: req.params.id, name: 'sparky' });
});

// 4. Add a route upload file(s)
// 4. Define route(s) to upload file(s)
app.post('/v1/pets/:id/photos', function(req, res, next) {
// DO something with the file
// files are found in req.files
// non-file multipar params can be found as such: req.body['my-param']
console.log(req.files);
// non-file multipart params can be found as such: req.body['my-param']

res.json({
files_metadata: req.files.map(f => ({
originalname: f.originalname,
encoding: f.encoding,
mimetype: f.mimetype,
// Buffer of file conents
// buffer: f.buffer,
buffer: f.buffer,
})),
});
});
Expand Down

0 comments on commit 2373b7e

Please sign in to comment.