In an attempt to develop a function that acquires a presigned s3 URL (call 1) and performs a PUT request to s3, I find myself contemplating the usage of a nested promise structure, which is commonly recognized as an anti-pattern.
Outlined in JavaScript/pseudocode:
uploadFile(file){
return new Promise((resolve, reject) => {
axios.get(getPresignedS3Url).then((url) => { return axios.put(file)}
})
}
let filePromises = files.forEach(file => uploadFile(file));
Promise.all((filePromises) => notifyUpload(filePromises));
The essential need is to return a promise from the uploadFile function to ensure all promises are resolved. What would be the correct approach to address this situation?