Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: explain complete event. #435

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/storage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ File.prototype.copy = function(destination, callback) {
* "CONTENT_DOWNLOAD_MISMATCH". If you receive this error, the best recourse is
* to try downloading the file again.
*
* NOTE: Readable streams will emit the `complete` event when the file is fully
* downloaded.
*
* @param {object=} options - Configuration object.
* @param {string|boolean} options.validation - Possible values: `"md5"`,
* `"crc32c"`, or `false`. By default, data integrity is validated with an
Expand Down Expand Up @@ -257,7 +260,10 @@ File.prototype.copy = function(destination, callback) {
*
* image.createReadStream()
* .pipe(fs.createWriteStream('/Users/stephen/Photos/image.png'))
* .on('error', function(err) {});
* .on('error', function(err) {})
* .on('complete', function() {
* // The file is fully downloaded.
* });
*
* //-
* // To limit the downloaded data to only a byte range, pass an options object.
Expand Down Expand Up @@ -426,6 +432,9 @@ File.prototype.createReadStream = function(options) {
*
* A File object can also be used to create files for the first time.
*
* NOTE: Writable streams will emit the `complete` event when the file is fully
* uploaded.
*
* @param {object=} options - Configuration object.
* @param {object=} options.metadata - Set the metadata for this file.
* @param {boolean=} options.resumable - Force a resumable upload. NOTE: When
Expand All @@ -452,7 +461,10 @@ File.prototype.createReadStream = function(options) {
*
* fs.createReadStream('/Users/stephen/Photos/birthday-at-the-zoo/panda.jpg')
* .pipe(image.createWriteStream())
* .on('error', function(err) {});
* .on('error', function(err) {})
* .on('complete', function() {
* // The file upload is complete.
* });
*
* //-
* // <h4>Uploading a File with Metadata</h4>
Expand Down