Closed rakeshkumar331 closed 3 years ago
Hi @rakeshkumar331 👋 It seems you're calling Storage.put
from within a map
function, so I can't be sure what values are being passed to Storage.put
. Could you confirm that only trying to upload one item works?
If uploading a single file works, you might want to wrap your map (which will return an array of promises), in a Promise.all
and await it like so:
// Put your code below this line.
async function onUpload(fileArr) {
if (fileArr.length > 0) {
console.log("fileArr", fileArr);
await Promise.all(
fileArr.map(async (obj) => {
try {
console.log({ Storage, Amplify });
console.log("Object =>", obj);
let baseData = await this.toBase64(obj);
console.log("Base Data =>", baseData);
const arrayBuffer = decode(baseData);
console.log("Array buffer =>", arrayBuffer);
let result = await Storage.put(`hub/${obj.name}`, arrayBuffer, {
contentType: obj.type,
});
console.log("S3 Upload Result =>", result);
} catch (err) {
console.log("Error in uploading", err);
}
})
);
}
}
Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you. Thank you!
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Before opening, please confirm:
JavaScript Framework
Vue
Amplify APIs
Storage
Amplify Categories
storage
Environment information
Describe the bug
My Code:
Expected behavior
Files should upload to S3 Storage
Reproduction steps
Install and configure
Code Snippet
Log output
aws-exports.js
const awsmobile = { "aws_project_region": "eu-west-2", "aws_cognito_identity_pool_id": "eu-west-2:xxx-xxxx-xxxx-xxxx-xxxxxxxx", "aws_cognito_region": "eu-west-2", "aws_user_pools_id": "eu-west-2_xxxxxxxx", "aws_user_pools_web_client_id": "xxxxxxxx", "oauth": {}, "aws_user_files_s3_bucket": "xxxxxxxx", "aws_user_files_s3_bucket_region": "eu-west-2" };
export default awsmobile;
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response