Skip to content

Commit

Permalink
Updates the request transport to pass through file objects to the Sla…
Browse files Browse the repository at this point in the history
…ck API correctly, by switching to formData mode with the request module when a file is supplied in the args to an API method.

Fixes #103
  • Loading branch information
Leah Jones authored and Leah Jones committed Feb 13, 2016
1 parent 9aed92c commit 477f113
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/clients/transports/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

var HttpsProxyAgent = require('https-proxy-agent');
var has = require('lodash').has;
var partial = require('lodash').partial;
var request = require('request');

Expand All @@ -22,11 +23,18 @@ var handleRequestTranportRes = function handleRequestTranportRes(cb, err, respon


var getRequestTransportArgs = function getReqestTransportArgs(args) {
return {
var transportArgs = {
url: args.url,
form: args.data,
headers: args.headers,
};

if (has(args.data, 'file')) {
transportArgs.formData = args.data;
} else {
transportArgs.form = args.data;
}

return transportArgs;
};


Expand Down

0 comments on commit 477f113

Please sign in to comment.