Skip to content

Commit

Permalink
Storage write streams should be able to use a pre-existing uri
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Stahl authored and stephenplusplus committed May 18, 2016
1 parent a8e4d27 commit 3d6fa8a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# Keep the list alphabetically sorted.

Anand Suresh <[email protected]>
Ben Stahl <[email protected]>
Brett Bergmann <[email protected]>
Burcu Dogan <[email protected]>
Hector Rovira <[email protected]>
Expand Down
2 changes: 2 additions & 0 deletions lib/storage/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,8 @@ Bucket.prototype.makePublic = function(options, callback) {
* @param {?error} callback.err - An error returned while making this request
* @param {module:storage/file} callback.file - The uploaded File.
* @param {object} callback.apiResponse - The full API response.
* @param {string} options.uri - The URI for an already-created resumable
* upload. See {module:storage/file#createResumableUpload}.
* @param {string|boolean} options.validation - Possible values: `"md5"`,
* `"crc32c"`, or `false`. By default, data integrity is validated with an
* MD5 checksum for maximum reliability. CRC32c will provide better
Expand Down
5 changes: 4 additions & 1 deletion lib/storage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,8 @@ File.prototype.createResumableUpload = function(options, callback) {
* `options.predefinedAcl = 'private'`)
* @param {boolean} options.public - Make the uploaded file public. (Alias for
* `options.predefinedAcl = 'publicRead'`)
* @param {string} options.uri - The URI for an already-created resumable
* upload. See {module:storage/file#createResumableUpload}.
* @param {string|boolean} options.validation - Possible values: `"md5"`,
* `"crc32c"`, or `false`. By default, data integrity is validated with an
* MD5 checksum for maximum reliability. CRC32c will provide better
Expand Down Expand Up @@ -1547,7 +1549,8 @@ File.prototype.startResumableUpload_ = function(dup, options) {
metadata: options.metadata,
predefinedAcl: options.predefinedAcl,
private: options.private,
public: options.public
public: options.public,
uri: options.uri
});

uploadStream
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"ent": "^2.2.0",
"extend": "^3.0.0",
"gce-images": "^0.2.0",
"gcs-resumable-upload": "^0.5.0",
"gcs-resumable-upload": "^0.6.0",
"google-auto-auth": "^0.2.0",
"google-proto-files": "^0.1.1",
"grpc": "^0.14.1",
Expand Down
10 changes: 7 additions & 3 deletions test/storage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,8 @@ describe('File', function() {
it('should start a simple upload if specified', function(done) {
var options = {
metadata: METADATA,
resumable: false
resumable: false,
customValue: true
};
var writable = file.createWriteStream(options);

Expand All @@ -1009,7 +1010,8 @@ describe('File', function() {
it('should start a resumable upload if specified', function(done) {
var options = {
metadata: METADATA,
resumable: true
resumable: true,
customValue: true
};
var writable = file.createWriteStream(options);

Expand Down Expand Up @@ -2180,7 +2182,8 @@ describe('File', function() {
metadata: {},
public: true,
private: false,
predefinedAcl: 'allUsers'
predefinedAcl: 'allUsers',
uri: 'http://resumable-uri'
};

file.generation = 3;
Expand All @@ -2198,6 +2201,7 @@ describe('File', function() {
assert.strictEqual(opts.predefinedAcl, options.predefinedAcl);
assert.strictEqual(opts.private, options.private);
assert.strictEqual(opts.public, options.public);
assert.strictEqual(opts.uri, options.uri);

setImmediate(done);
return through();
Expand Down

0 comments on commit 3d6fa8a

Please sign in to comment.