You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here I created an empty array of promises to store each response of the upload call. Next, I am mapping images array to upload calls with a single image and promises.push is saving that response in promises array.
RNS3.put
Next, I defined my uploadImageToS3 a method like its mentioned in the example of react-native-aws3.
constfile={uri: `${image.path}`,name: image.path.substring(image.path.lastIndexOf('/')+1),//extracting filename from image pathtype: image.mime,};
returnnewPromise((resolve,reject)=>{RNS3.put(file,options).then(res=>{if(res.status===201){const{postResponse}=res.body;resolve({src: postResponse.location,});}else{console.log('error uploading to s3',res);}}).catch(err=>{console.log('error uploading to s3',err);reject(err);});});};
This method is returning the promise of URL/location of the image as an object having value src.
Now I combined all promises with Promise.all function.
Promise.all(promises).then(uploadedImgs=>{console.log('Yayy, all images are uploaded successfully',uploadedImgs)});
Creating a new issue to enhance attention
If you are wondering how to upload multiple files to S3 bucket...
Below worked for me!!!
Original Source
Here I created an empty array of promises to store each response of the upload call. Next, I am mapping images array to upload calls with a single image and promises.push is saving that response in promises array.
RNS3.put
Next, I defined my uploadImageToS3 a method like its mentioned in the example of react-native-aws3.
This method is returning the promise of URL/location of the image as an object having value src.
Now I combined all promises with Promise.all function.
uploadedImgs array will look like this
The text was updated successfully, but these errors were encountered: