Get upload progress for Google Drive NodeJS client?

前端 未结 2 1784
时光取名叫无心
时光取名叫无心 2021-01-06 11:42

After we get the request object from req = drive.files.insert how to use it find file upload progress ?

I searched for it in the req string

2条回答
  •  感情败类
    2021-01-06 12:23

    Every request to the API returns a request object, allowing you to track the request's progress or general information about the request. You need to add a handler for a request part received.

    Here is the sample code:

    part.addListener("request", function(received) {
        // Calculate upload progress
        var progress = (stream.bytesReceived / stream.bytesTotal * 100).toFixed(2);
        var mb = (stream.bytesTotal / 1024 / 1024).toFixed(1);
    
        sys.debug("Uploading " + mb + "mb (" + progress + "%)");
    

    You can find the documentation in this blog.

提交回复
热议问题