Kong / Kong/unirest-nodejs

multipart support doesnt seem to work

Open
#58 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
953
Forks
164
PR merge metrics
No merged PRs in 30d

Description

Say I have this code:

var request = unirest.post(endpoint);
request.part({
'Content-Disposition': 'file; filename="inflation.tiff"',
'content-type': 'image/tiff',
'Content-Transfer-Encoding' : 'base64',
body: base64Image
});

Couple of things:

1) index.js looks for "content-type" which is case sensitive.
2) This code errors out with:
/home/jnankin/node_modules/unirest/index.js:321
$this.options.multipart.push(options);
^
TypeError: Cannot call method 'push' of undefined

Looking at index.js, I don't see where $this.options.multipart would ever have been set. It's only set if !$this._multipart, but _multipart is definied by default.

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect index.js around the multipart handling and the failing line 321, starting with how _multipart and options.multipart are initialized. Verify that request.part accepts the shown header casing and no longer throws when adding the part; the issue is done when both reported failures are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.