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

Commit f4312ac

Browse files
committed
flatten the options passed to send-files-stream. files/* code passes querystring options flatly and util/* code passes it under the 'qs' property, requiring this flattening. files/* should probably send options under 'qs'.
1 parent 4d87730 commit f4312ac

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/util/fs-add.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ module.exports = (send) => {
3030
return callback(new Error('"path" must be a string'))
3131
}
3232

33-
sendOneFile(path, opts, callback)
33+
sendOneFile(path, { qs: opts }, callback)
3434
})
3535
}

src/util/url-add.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const requestWithRedirect = (url, opts, sendOneFile, callback) => {
4848
}
4949
requestWithRedirect(redirection, opts, sendOneFile, callback)
5050
} else {
51-
sendOneFile(res, opts, callback)
51+
sendOneFile(res, { qs: opts }, callback)
5252
}
5353
}).end()
5454
}

src/utils/send-files-stream.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = (send, path) => {
3232
let ended = false
3333
let writing = false
3434

35-
options = options || {}
35+
options = options ? Object.assign({}, options, options.qs) : {}
3636

3737
const multipart = new Multipart()
3838

@@ -43,7 +43,7 @@ module.exports = (send, path) => {
4343
retStream._write = (file, enc, _next) => {
4444
const next = once(_next)
4545
try {
46-
const files = prepareFile(file, Object.assign({}, options, options.qs))
46+
const files = prepareFile(file, options)
4747
.map((file) => Object.assign({headers: headers(file)}, file))
4848

4949
writing = true

0 commit comments

Comments
 (0)