Skip to content

Commit

Permalink
storage: pass metadata during stream upload
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Feb 2, 2015
1 parent 5284a39 commit 89b74b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ function makeWritableStream(dup, options, onComplete) {
// Write the metadata to the request.
stream.write('--' + boundary + '\n');
stream.write('Content-Type: application/json\n\n');
stream.write(JSON.stringify(options.metadata));
stream.write(JSON.stringify({
metadata: options.metadata
}));
stream.write('\n\n');
stream.write('--' + boundary + '\n');
stream.write('Content-Type: ' + streamType + '\n\n');
Expand Down
8 changes: 6 additions & 2 deletions regression/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,12 @@ describe('storage', function() {
});
});

it('should write metadata', function(done) {
it.only('should write metadata', function(done) {
var options = {
metadata: { contentType: 'image/png' },
metadata: {
contentType: 'image/png',
property: 'value'
},
resumable: false
};

Expand All @@ -386,6 +389,7 @@ describe('storage', function() {
file.getMetadata(function(err, metadata) {
assert.ifError(err);
assert.equal(metadata.contentType, options.metadata.contentType);
assert.equal(metadata.metadata.property, options.metadata.property);
file.delete(done);
});
});
Expand Down
4 changes: 3 additions & 1 deletion test/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ describe('common/util', function() {
assert(endFirstBoundaryIdx > startFirstBoundaryIdx);
assert(endBoundaryIdx > -1);

assert(written.indexOf(JSON.stringify(metadata)) > -1);
assert(written.indexOf(JSON.stringify({
metadata: metadata
})) > -1);

done();
};
Expand Down

0 comments on commit 89b74b0

Please sign in to comment.