Skip to content

Commit 6a299fc

Browse files
committed
Merge pull request #435 from stephenplusplus/spp--storage-document-complete-event
storage: explain `complete` event.
2 parents 7fb3c17 + 666ba75 commit 6a299fc

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

lib/storage/file.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ File.prototype.copy = function(destination, callback) {
227227
* "CONTENT_DOWNLOAD_MISMATCH". If you receive this error, the best recourse is
228228
* to try downloading the file again.
229229
*
230+
* NOTE: Readable streams will emit the `complete` event when the file is fully
231+
* downloaded.
232+
*
230233
* @param {object=} options - Configuration object.
231234
* @param {string|boolean} options.validation - Possible values: `"md5"`,
232235
* `"crc32c"`, or `false`. By default, data integrity is validated with an
@@ -257,7 +260,10 @@ File.prototype.copy = function(destination, callback) {
257260
*
258261
* image.createReadStream()
259262
* .pipe(fs.createWriteStream('/Users/stephen/Photos/image.png'))
260-
* .on('error', function(err) {});
263+
* .on('error', function(err) {})
264+
* .on('complete', function() {
265+
* // The file is fully downloaded.
266+
* });
261267
*
262268
* //-
263269
* // To limit the downloaded data to only a byte range, pass an options object.
@@ -426,6 +432,9 @@ File.prototype.createReadStream = function(options) {
426432
*
427433
* A File object can also be used to create files for the first time.
428434
*
435+
* NOTE: Writable streams will emit the `complete` event when the file is fully
436+
* uploaded.
437+
*
429438
* @param {object=} options - Configuration object.
430439
* @param {object=} options.metadata - Set the metadata for this file.
431440
* @param {boolean=} options.resumable - Force a resumable upload. NOTE: When
@@ -452,7 +461,10 @@ File.prototype.createReadStream = function(options) {
452461
*
453462
* fs.createReadStream('/Users/stephen/Photos/birthday-at-the-zoo/panda.jpg')
454463
* .pipe(image.createWriteStream())
455-
* .on('error', function(err) {});
464+
* .on('error', function(err) {})
465+
* .on('complete', function() {
466+
* // The file upload is complete.
467+
* });
456468
*
457469
* //-
458470
* // <h4>Uploading a File with Metadata</h4>

0 commit comments

Comments
 (0)