6
votes

I am using @google-cloud/storage npm package for file upload from NodeJS. It is uploading file to google cloud bucket successfully. Reference: https://github.com/GoogleCloudPlatform/google-cloud-node/tree/storage-1.1.0#cloud-storage-ga

But for larger files(size > 20 MB), I need to show upload progress status on browser(Client - Chrome, firefox, etc).

I am submitting AJAX request with file as formdata to REST API(written using NodeJS) and REST API uploads file to Google Cloud Storage buckets. Note: I don't want to upload files directly from UI(Browser) to Google cloud storage.

But, I am not getting how to send back uploading file progress to UI from Google-Cloud-Storage via NodeJS REST API.

Would appreciate your suggestion or relevant references.

1

1 Answers

0
votes
  1. Use XMLHttpRequest to track your progress on NodeJS, using an eventlistener

  2. Open a socket and transmit progress messages from your event listener and consume them on the client

References:

  1. https://stackoverflow.com/a/30635818/4465100
  2. http://blog.fossasia.org/file-upload-progress-in-a-node-app-using-socket-io/