简体   繁体   English

使用NodeJS REST API通过Google云端存储获取文件上传进度

[英]Get file uploading progress with Google Cloud Storage using NodeJS REST API

I am using @google-cloud/storage npm package for file upload from NodeJS. 我正在使用@ google-cloud / storage npm包从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 参考: 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). 但对于较大的文件(大小> 20 MB),我需要在浏览器上显示上传进度状态(客户端 - Chrome,Firefox等)。

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. 我将带有formdata文件的AJAX请求提交到REST API(使用NodeJS编写)和REST API上传文件到Google Cloud Storage存储桶。 Note: I don't want to upload files directly from UI(Browser) to Google cloud storage. 注意: 我不想直接从UI(浏览器)上传文件到Google云端存储。

But, I am not getting how to send back uploading file progress to UI from Google-Cloud-Storage via NodeJS REST API. 但是,我没有得到如何通过NodeJS REST API将文件进度从Google-Cloud-Storage发送回UI。

Would appreciate your suggestion or relevant references. 非常感谢您的建议或相关参考。

  1. Use XMLHttpRequest to track your progress on NodeJS, using an eventlistener 使用XMLHttpRequest使用eventlistener跟踪NodeJS的进度

  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 https://stackoverflow.com/a/30635818/4465100
  2. http://blog.fossasia.org/file-upload-progress-in-a-node-app-using-socket-io/ http://blog.fossasia.org/file-upload-progress-in-a-node-app-using-socket-io/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用nodejs gcloud api在Google云端存储中移动/重命名文件夹 - Move/rename folder in Google Cloud Storage using nodejs gcloud api 无法使用NodeJS API将元数据附加到Google云端存储 - Unable to attach metadata to Google Cloud Storage using NodeJS API 使用 nodejs gcloud api 删除 Google Cloud Storage 中的文件夹 - Delete folder in Google Cloud Storage using nodejs gcloud api 如何使用nodejs从谷歌云存储获取链接文件 - how to get link file from google cloud storage use nodejs 从 REST API 获取图像并将其上传到 Firebase 云存储使用 Z035489FF8D324159ZEEA 功能 Cloud Storage - Getting image from REST API and uploading it to Firebase Cloud Storage using Firebase Cloud Functions 如何使用nodejs将内存文件数据上传到谷歌云存储? - How to upload an in memory file data to google cloud storage using nodejs? 无法将文件上传到谷歌云存储 - Trouble uploading file to google cloud storage 使用 Cloud Functions 将图像上传到 Google Storage - Uploading an image to Google Storage using Cloud Functions 使用Cloud Functions REST API请求将文件存储在Firebase存储中 - Store file in Firebase Storage using Cloud Functions REST API request 使用 NodeJS 将文件上传到谷歌云存储 - Upload file to google cloud storage with NodeJS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM