Skip to content

Commit

Permalink
gcs-resumable-upload now supports providing an offset
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 3d6fa8a commit b877420
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/storage/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,8 @@ Bucket.prototype.makePublic = function(options, callback) {
* `options.metadata.contentEncoding` to `gzip`.
* @param {object} options.metadata - See an
* [Objects: insert request body](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request_properties_JSON).
* @param {string} options.offset - The starting byte of the upload stream, for
* resuming an interrupted upload. Defaults to 0.
* @param {string} options.predefinedAcl - Apply a predefined set of access
* controls to this object.
*
Expand Down
11 changes: 7 additions & 4 deletions lib/storage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,8 @@ File.prototype.createResumableUpload = function(options, callback) {
* `options.metadata.contentEncoding` to `gzip`.
* @param {object=} options.metadata - See an
* [Objects: insert request body](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request_properties_JSON).
* @param {boolean} options.resumable - Force a resumable upload. NOTE: When
* working with streams, the file format and size is unknown until it's
* completely consumed. Because of this, it's best for you to be explicit
* for what makes sense given your input.
* @param {string} options.offset - The starting byte of the upload stream, for
* resuming an interrupted upload. Defaults to 0.
* @param {string} options.predefinedAcl - Apply a predefined set of access
* controls to this object.
*
Expand All @@ -747,6 +745,10 @@ File.prototype.createResumableUpload = function(options, callback) {
* `options.predefinedAcl = 'private'`)
* @param {boolean} options.public - Make the uploaded file public. (Alias for
* `options.predefinedAcl = 'publicRead'`)
* @param {boolean} options.resumable - Force a resumable upload. NOTE: When
* working with streams, the file format and size is unknown until it's
* completely consumed. Because of this, it's best for you to be explicit
* for what makes sense given your input.
* @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"`,
Expand Down Expand Up @@ -1547,6 +1549,7 @@ File.prototype.startResumableUpload_ = function(dup, options) {
file: this.name,
generation: this.generation,
metadata: options.metadata,
offset: options.offset,
predefinedAcl: options.predefinedAcl,
private: options.private,
public: options.public,
Expand Down
2 changes: 2 additions & 0 deletions test/storage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,7 @@ describe('File', function() {
it('should start a resumable upload', function(done) {
var options = {
metadata: {},
offset: 1234,
public: true,
private: false,
predefinedAcl: 'allUsers',
Expand All @@ -2198,6 +2199,7 @@ describe('File', function() {
assert.strictEqual(opts.file, file.name);
assert.strictEqual(opts.generation, file.generation);
assert.strictEqual(opts.metadata, options.metadata);
assert.strictEqual(opts.offset, options.offset);
assert.strictEqual(opts.predefinedAcl, options.predefinedAcl);
assert.strictEqual(opts.private, options.private);
assert.strictEqual(opts.public, options.public);
Expand Down

0 comments on commit b877420

Please sign in to comment.