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

progress tracking when uploading big file #956

Closed
gamaya-developer opened this issue Dec 14, 2019 · 2 comments · Fixed by #1074
Closed

progress tracking when uploading big file #956

gamaya-developer opened this issue Dec 14, 2019 · 2 comments · Fixed by #1074
Assignees
Labels
api: storage Issues related to the googleapis/nodejs-storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@gamaya-developer
Copy link

gamaya-developer commented Dec 14, 2019

Maybe I missed something but couldn't find a way to track progress during uploading. Is it possible to do it now?

I think it would be great to have an option for example:

const options = { onProgress: (data) => { console.log(data.loadedBytes) } };

await storage.bucket(bucketName).upload(filename, options);

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Dec 14, 2019
@bcoe bcoe added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Dec 16, 2019
@yoshi-automation yoshi-automation removed the triage me I really want to be triaged. label Dec 16, 2019
@google-cloud-label-sync google-cloud-label-sync bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Jan 29, 2020
@1c7
Copy link

1c7 commented Feb 5, 2021

Hi, can anyone update the document and provide an example on how to get upload progress?

@1c7
Copy link

1c7 commented Feb 5, 2021

This works

const storage = new Storage({....})
const bucket = storage.bucket("[bucket_name]")
const remote_file = bucket.file("[file_name]")

fs.createReadStream("[your_local_file_path]")
  .pipe(remote_file.createWriteStream())
  .on('error', function (err) {})
  .on('progress', function (p) {
    console.log(p);
    // { bytesWritten: 67371008, contentLength: '*' }
  })
  .on('finish', function () {
    // The file upload is complete.
  });

image

Node version

image

package.json

"@google-cloud/storage": "^5.7.4",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants