yakovkhalinsky / backblaze-b2

Node.js Library for the Backblaze B2 Storage Service
MIT License
189 stars 58 forks source link

on upload progress #125

Open joyjames143 opened 1 year ago

joyjames143 commented 1 year ago

I want to know how to code in such a way that the onUploadProgress works because in my code the file is getting uploaded but I can't able to get the upload progress

the below is my code for uploading a file

router.post("/uploadvideo", upload.single('file') ,async(req,res)=>{ let b2 = new B2({ applicationKeyId: 'my-app-id', applicationKey: 'my-app-key' }); await b2.authorize(); const file = req.file; const result = await b2.getUploadUrl('my-bucket-id'); let resultdata = result.data const dictionary = new Map(Object.entries(resultdata));

b2.uploadFile({
    fileName: 'video4.zip', 
    data: file.buffer,
    bucketId: 'boss-cloud',
    uploadUrl:dictionary.get("uploadUrl"),
    uploadAuthToken:dictionary.get("authorizationToken"),
    onUploadProgress: function (event) {
      console.log("joker")
        console.log(`Upload progress: ${event.percent}%`)
    }
  }).then((response) => {
    console.log("uploaded")
    return res.send("uploaded")
  }).catch((error) => {
    console.error(error);
  });

})

in this code, I am able to upload any file but I can't able to get the upload progress

it is a node.js application and I am using "Backblaze-b2": "^1.7.0".

the same issue for the download progress code also I am ale to download ut not able to see the download progress while downloading

I want to know how to get the upload progress and download progress

can I get it? if so then how?

if not? why can't I get it

nkwelleepiengomejr commented 6 months ago

Same here