Skip to content

Commit b877420

Browse files
Ben Stahlstephenplusplus
Ben Stahl
authored andcommitted
gcs-resumable-upload now supports providing an offset
1 parent 3d6fa8a commit b877420

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lib/storage/bucket.js

+2
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,8 @@ Bucket.prototype.makePublic = function(options, callback) {
938938
* `options.metadata.contentEncoding` to `gzip`.
939939
* @param {object} options.metadata - See an
940940
* [Objects: insert request body](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request_properties_JSON).
941+
* @param {string} options.offset - The starting byte of the upload stream, for
942+
* resuming an interrupted upload. Defaults to 0.
941943
* @param {string} options.predefinedAcl - Apply a predefined set of access
942944
* controls to this object.
943945
*

lib/storage/file.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,8 @@ File.prototype.createResumableUpload = function(options, callback) {
719719
* `options.metadata.contentEncoding` to `gzip`.
720720
* @param {object=} options.metadata - See an
721721
* [Objects: insert request body](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request_properties_JSON).
722-
* @param {boolean} options.resumable - Force a resumable upload. NOTE: When
723-
* working with streams, the file format and size is unknown until it's
724-
* completely consumed. Because of this, it's best for you to be explicit
725-
* for what makes sense given your input.
722+
* @param {string} options.offset - The starting byte of the upload stream, for
723+
* resuming an interrupted upload. Defaults to 0.
726724
* @param {string} options.predefinedAcl - Apply a predefined set of access
727725
* controls to this object.
728726
*
@@ -747,6 +745,10 @@ File.prototype.createResumableUpload = function(options, callback) {
747745
* `options.predefinedAcl = 'private'`)
748746
* @param {boolean} options.public - Make the uploaded file public. (Alias for
749747
* `options.predefinedAcl = 'publicRead'`)
748+
* @param {boolean} options.resumable - Force a resumable upload. NOTE: When
749+
* working with streams, the file format and size is unknown until it's
750+
* completely consumed. Because of this, it's best for you to be explicit
751+
* for what makes sense given your input.
750752
* @param {string} options.uri - The URI for an already-created resumable
751753
* upload. See {module:storage/file#createResumableUpload}.
752754
* @param {string|boolean} options.validation - Possible values: `"md5"`,
@@ -1547,6 +1549,7 @@ File.prototype.startResumableUpload_ = function(dup, options) {
15471549
file: this.name,
15481550
generation: this.generation,
15491551
metadata: options.metadata,
1552+
offset: options.offset,
15501553
predefinedAcl: options.predefinedAcl,
15511554
private: options.private,
15521555
public: options.public,

test/storage/file.js

+2
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,7 @@ describe('File', function() {
21802180
it('should start a resumable upload', function(done) {
21812181
var options = {
21822182
metadata: {},
2183+
offset: 1234,
21832184
public: true,
21842185
private: false,
21852186
predefinedAcl: 'allUsers',
@@ -2198,6 +2199,7 @@ describe('File', function() {
21982199
assert.strictEqual(opts.file, file.name);
21992200
assert.strictEqual(opts.generation, file.generation);
22002201
assert.strictEqual(opts.metadata, options.metadata);
2202+
assert.strictEqual(opts.offset, options.offset);
22012203
assert.strictEqual(opts.predefinedAcl, options.predefinedAcl);
22022204
assert.strictEqual(opts.private, options.private);
22032205
assert.strictEqual(opts.public, options.public);

0 commit comments

Comments
 (0)