javascript – Is there any way to upload multiple images to aws-sdk without using “for” loop or any other loop function?

Sharing a small snippet of current code using for loop;

imageArr.forEach(async (file, index) => {
     
      let contentType = file.type || "image/jpeg";
      let contentDeposition = 'inline;filename="' + file.name + '"';
      const base64 = await readFile(file.uri, "base64");
      const arrayBuffer = decode(base64);
      const filename = file.name;

      const params = {
        Bucket: aws_upload_config.bucketName,
        Key: filename,
        Body: arrayBuffer,
        ContentDisposition: contentDeposition,
        ContentType: contentType,
      };

      s3bucket.upload(params, (err, data) => {
        if (err) {
          throw err;
        }
        let url = data?.Location;
        imageURLs = [
          ...imageURLs,
          url,
        ];
      });
});

Is there any way to do this multiple image upload without any loop function; that upload each image one by one.

Since this function is time consuming.

Read more here: Source link