Skip to content

Commit

Permalink
Merge pull request #785 from stripe/jlomas/fix-file-create
Browse files Browse the repository at this point in the history
Fix file uploads with nested params
  • Loading branch information
brandur-stripe committed Jan 30, 2020
2 parents 8f6b0f8 + 9913bdf commit a6181ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/multipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ const multipartDataGenerator = (method, data, headers) => {
return `"${s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ')}"`;
}

for (const k in utils.flattenAndStringify(data)) {
const v = data[k];
const flattenedData = utils.flattenAndStringify(data);

for (const k in flattenedData) {
const v = flattenedData[k];
push(`--${segno}`);
if (v.hasOwnProperty('data')) {
push(
Expand Down
18 changes: 16 additions & 2 deletions testUtils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,22 @@ const utils = (module.exports = {
if (host) {
req.host = host;
}
stripeInstance.REQUESTS.push(req);
cb.call(this, null, {});

const handleMockRequest = (err, req) => {
stripeInstance.REQUESTS.push(req);
cb.call(this, err, {});
};

if (this.requestDataProcessor) {
this.requestDataProcessor(
method,
data,
options.headers,
handleMockRequest
);
} else {
handleMockRequest(null, req);
}
};
}

Expand Down

0 comments on commit a6181ec

Please sign in to comment.