-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: getFileStream() can accept non file request #17
Conversation
```js const stream = await ctx.getFileStream({ required: false }); if (stream.filename) { console.log('uploaded ' + stream.filename); } else { console.log('file not exists'); } ``` closes eggjs/egg#2178
app/extend/context.js
Outdated
@@ -28,15 +35,25 @@ module.exports = { | |||
* console.log(stream.fields); | |||
* ``` | |||
* @method Context#getFileStream | |||
* @param {Object} options | |||
* - {Boolean} options.required - required file submit, default is true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requireFile ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好
Codecov Report
@@ Coverage Diff @@
## master #17 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 3 3
Lines 50 56 +6
=====================================
+ Hits 50 56 +6
Continue to review full report at Codecov.
|
async uploadNotRequiredFile() { | ||
const ctx = this.ctx; | ||
// file not required | ||
const stream = await ctx.getFileStream({ requireFile: false }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
2.1.0 |
closes eggjs/egg#2178
Checklist
npm test
passesAffected core subsystem(s)
Description of change