Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Adding support for file upload (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanguimam authored Jun 8, 2021
1 parent e9388e3 commit 7617be0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,22 @@ module.exports = {
};
```

## FILE UPLOAD
Ex: return file name<br/>
formDataName = 'file'

``` javascript
module.exports = {
render: (req, res) => {
if (callback) {
res.send({fileName: req.files.file.name});
} else {
res.send(res.body);
}
}
}
```

## HTTPS

If you want to run dyson over SSL you have to provide a (authority-signed or self-signed) certificate into the `options.https` the same way it's required for NodeJS built-in `https` module. Example:
Expand Down
2 changes: 2 additions & 0 deletions lib/dyson.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const delay = require('./delay');
const proxy = require('./proxy');
const requireParameter = require('./parameter');
const rawBody = require('./raw-body');
const fileUpload = require('express-fileupload');

/*
* There are roughly 3 steps to initialize dyson:
Expand Down Expand Up @@ -65,6 +66,7 @@ const installMiddleware = (app, options) => {
app.use(favicon(`${__dirname}/favicon.ico`));
app.use(bodyParser.json(bodyParserOptions));
app.use(bodyParser.urlencoded(bodyParserUrlOptions));
app.use(fileUpload());

return app;
};
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-fileupload": "0.4.0",
"lodash": "^4.17.21",
"request": "^2.88.2",
"require-directory": "^2.1.1",
Expand Down

0 comments on commit 7617be0

Please sign in to comment.