mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-21 17:29:43 +00:00
companion,xhr-upload: option to set multipart http method
fixes #2019 (we can all go one year backwards once this is merged)
This commit is contained in:
parent
746bbcbbc5
commit
4ed7508f78
2 changed files with 5 additions and 1 deletions
|
|
@ -36,6 +36,7 @@ class Uploader {
|
|||
* @property {any} companionOptions
|
||||
* @property {any=} storage
|
||||
* @property {any=} headers
|
||||
* @property {string=} httpMethod
|
||||
*
|
||||
* @param {UploaderOptions} options
|
||||
*/
|
||||
|
|
@ -112,6 +113,7 @@ class Uploader {
|
|||
uploadUrl: req.body.uploadUrl,
|
||||
protocol: req.body.protocol,
|
||||
metadata: req.body.metadata,
|
||||
httpMethod: req.body.httpMethod,
|
||||
size: size,
|
||||
fieldname: req.body.fieldname,
|
||||
pathPrefix: `${req.companion.options.filePath}`,
|
||||
|
|
@ -455,8 +457,9 @@ class Uploader {
|
|||
}
|
||||
}
|
||||
)
|
||||
const httpMethod = (this.options.httpMethod || '').toLowerCase() === 'put' ? 'put' : 'post'
|
||||
const headers = headerSanitize(this.options.headers)
|
||||
request.post({ url: this.options.endpoint, headers, formData, encoding: null }, (error, response, body) => {
|
||||
request[httpMethod]({ url: this.options.endpoint, headers, formData, encoding: null }, (error, response, body) => {
|
||||
if (error) {
|
||||
logger.error(error, 'upload.multipart.error')
|
||||
this.emitError(error)
|
||||
|
|
|
|||
|
|
@ -356,6 +356,7 @@ module.exports = class XHRUpload extends Plugin {
|
|||
size: file.data.size,
|
||||
fieldname: opts.fieldName,
|
||||
metadata: fields,
|
||||
httpMethod: this.opts.method,
|
||||
headers: opts.headers
|
||||
}).then((res) => {
|
||||
const token = res.token
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue