Skip to content

Commit

Permalink
test for upload multipart files
Browse files Browse the repository at this point in the history
  • Loading branch information
SmilingXinyi committed Jun 3, 2019
1 parent fbb63ea commit cabb43b
Show file tree
Hide file tree
Showing 5 changed files with 1,867 additions and 1,831 deletions.
6 changes: 4 additions & 2 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ export default class Context {
options.body = (function (params) {
const fd = new FormData()
for (const key in params) {
if (/\[\]/m.test(params[key]) && params[key] instanceof Array) {
if (/\[\]/m.test(key)) {
// example: upload multipart files
const tempKey = params[key].replace('[]', '')
if (!(params[key] instanceof Array))
params[key] = [params[key]]
const tempKey = key.replace('[]', '')
params[key].forEach(item => {
fd.append(tempKey, item)
})
Expand Down
Loading

0 comments on commit cabb43b

Please sign in to comment.