0

Im traing to upload multiples images from an array of files. The thing is i want to keep watching the progress of each file.

I have this function

const handleChange = ({ target: { files } }) => {
   const uploadingFiles = [...files].map(file => {
     uploadFile(file, fieldName, (progress, url) => {
       // I would like to return this properties for the map but clarly I can not do that
        return {progress, url}
       // 
     })
   })
 }
// i would like to have an array like this, and keep watching for the progress...
const uploadingFiles = [
{progress:0,url:null},
{prgress:28:url:null},
{progress:100, url:'https://...'}

Is any posible way to do that ?

raul zarza
  • 33
  • 5
  • Does this answer your question? [How do I convert an existing callback API to promises?](https://stackoverflow.com/questions/22519784/how-do-i-convert-an-existing-callback-api-to-promises) – Krzysztof Krzeszewski Oct 03 '22 at 20:02
  • thanks but not really i dont want to convert it, i need use cb for looking the progress in each element. – raul zarza Oct 03 '22 at 21:03
  • What you just said does not make any sense. It's not like the callback is called multiple times. Each call to uploadFile for each file can be converted into a separate promise – Krzysztof Krzeszewski Oct 04 '22 at 06:59

0 Answers0