Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

fix multipart/form-data #948

Merged
merged 1 commit into from
Jul 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/utils/send-files-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const once = require('once')
const prepareFile = require('./prepare-file')
const Multipart = require('./multipart')

function headers (file) {
const name = file.path
function headers (file, i) {
const filename = file.path
? encodeURIComponent(file.path)
: ''

const header = { 'Content-Disposition': `file; filename="${name}"` }
const header = { 'Content-Disposition': `form-data; name="data${i}"; filename="${filename}"` }

if (!file.content) {
header['Content-Type'] = 'application/x-directory'
Expand Down Expand Up @@ -43,7 +43,7 @@ module.exports = (send, path) => {
const next = once(_next)
try {
const files = prepareFile(file, options)
.map((file) => Object.assign({ headers: headers(file) }, file))
.map((file, i) => Object.assign({ headers: headers(file, i) }, file))

writing = true
eachSeries(
Expand Down