'All files do not get uploaded while uploading multiple files to s3 bucket

Here's my code for uploading multiple files to s3 bucket using rn-fetch-blob:

pictureUris.map(async (picture, index) => {
            s3.getSignedUrl(
              'putObject',
              {
                Key: 'key',
                Bucket: 'bucket',
                Tagging: 'tag',
              },
              async (err, url) => {
                if (url) {
                  RNFetchBlob.fetch(
                    'PUT',
                    url,
                    {
                      'x-amz-tagging': 'tag',
                    },
                    RNFetchBlob.wrap(`path-to-file`),
                  )
                    .then((res) => {               
                    })
                    .catch((uploadErr) => {
  
                    });
                }
                if (err) {
                  console.log('SIGNED URL ERR', err);
                  
                }
              },
            );
          })

When I try to upload, say, 20 files, only 17 are visible in the bucket. The code never hits the catch block and yet some files do not get uploaded.

(PS: I've observed that if the upload count is 30, 26 files show up in the bucket. If the upload count is 20, 17 files show up. And, if the upload count is 10, 9 files show up. I've observed this repeatedly, but it could very well be a coincidence.)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source