Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow passing { key: Buffer } directly for multipart uploads
  • Loading branch information
tomas committed Sep 12, 2017
1 parent 6e1e6a5 commit bc36e10
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/multipart.js
Expand Up @@ -20,12 +20,14 @@ exports.build = function(data, boundary, callback) {
};

for (var key in object) {

var value = object[key];
if (value === null || typeof value == 'undefined') {
done();
} else if (Buffer.isBuffer(value)) {
var part = { buffer: value, content_type: 'application/octet-stream' };
generate_part(key, part, boundary, done);
} else {
var part = (value.buffer || value.file || value.content_type) ? value : {value: value};
var part = (value.buffer || value.file || value.content_type) ? value : { value: value };
generate_part(key, part, boundary, done);
}
}
Expand Down

0 comments on commit bc36e10

Please sign in to comment.