How to use gcs-resumable-upload - 4 common examples

To help you get started, we’ve selected a few gcs-resumable-upload examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / gcs-resumable-upload / samples / quickstart.js View on Github external
return new Promise((resolve, reject) => {
    fs.createReadStream(file)
      .pipe(upload({ bucket, file }))
      .on('progress', (progress) => {
        console.log('Progress event:')
        console.log('\t bytes: ', progress.bytesWritten);
        const pct = Math.round(progress.bytesWritten/fileSize*100);
        console.log(`\t ${pct}%`)
      })
      .on('finish', () => {
        console.log('Upload complete!');
        resolve();
      })
      .on('error', (err) => {
        console.error('There was a problem uploading the file :(');
        reject(err);
      })
    });
}
github googleapis / nodejs-storage / src / file.js View on Github external
startResumableUpload_(dup, options) {
    options = extend(
      {
        metadata: {},
      },
      options
    );

    const uploadStream = resumableUpload.upload({
      authClient: this.storage.authClient,
      bucket: this.bucket.name,
      file: this.name,
      generation: this.generation,
      key: this.encryptionKey,
      kmsKeyName: this.kmsKeyName,
      metadata: options.metadata,
      offset: options.offset,
      predefinedAcl: options.predefinedAcl,
      private: options.private,
      public: options.public,
      uri: options.uri,
      userProject: options.userProject,
    });

    uploadStream
github googleapis / nodejs-storage / src / file.js View on Github external
createResumableUpload(options, callback) {
    if (is.fn(options)) {
      callback = options;
      options = {};
    }

    resumableUpload.createURI(
      {
        authClient: this.storage.authClient,
        bucket: this.bucket.name,
        file: this.name,
        generation: this.generation,
        key: this.encryptionKey,
        kmsKeyName: this.kmsKeyName,
        metadata: options.metadata,
        offset: options.offset,
        origin: options.origin,
        predefinedAcl: options.predefinedAcl,
        private: options.private,
        public: options.public,
        userProject: options.userProject,
      },
      callback
github googleapis / google-cloud-node / packages / storage / src / file.js View on Github external
File.prototype.createResumableUpload = function(options, callback) {
  if (is.fn(options)) {
    callback = options;
    options = {};
  }

  resumableUpload.createURI({
    authClient: this.bucket.storage.authClient,
    bucket: this.bucket.name,
    file: this.name,
    generation: this.generation,
    metadata: options.metadata,
    origin: options.origin,
    predefinedAcl: options.predefinedAcl,
    private: options.private,
    public: options.public,
    userProject: options.userProject
  }, callback);
};

gcs-resumable-upload

Upload a file to Google Cloud Storage with built-in resumable behavior

MIT
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis

Popular gcs-resumable-upload functions