How to upload to S3 bucket?
See original GitHub issueHi, Is there a way to upload to S3 bucket?
I tried it like this and got the following error:
const options = {
url: 'https://s3.amazonaws.com/mybucketname',
method: 'POST',
path: uri, // /Users/user/Library/.../5D94544E-E33B-475E-BB3F-5BFA72E15A63.jpg
type: 'multipart',
headers: {
},
field: 'uploaded_media',
region: "us-east-1",
accessKey: 'myaccesskey',
secretKey: "mysecretkey",
// Below are options only supported on Android
notification: {
enabled: true
}
};
Upload.startUpload(options).then((uploadId) => {
console.log('Upload started');
Upload.addListener('progress', uploadId, (data) => {
console.log(`Progress: ${data.progress}%`)
});
Upload.addListener('error', uploadId, (data) => {
console.log(`Error: ${data.error}%`)
});
Upload.addListener('cancelled', uploadId, (data) => {
console.log(`Cancelled!`)
});
Upload.addListener('completed', uploadId, (data) => {
console.log('Completed!', data)
})
}).catch((err) => {
console.log('Upload error!', err)
});
and i got this error:
{id: "9", responseCode: 400, responseBody: "<?xml version="1.0" encoding="UTF-8"?>↵<Error><Cod…lyaNSBlMomTWSgYgOloDwFtOReU01RA=</HostId></Error>"}
id
:
"9"
responseBody
:
"<?xml version="1.0" encoding="UTF-8"?>↵<Error><Code>MaxPostPreDataLengthExceeded</Code><Message>Your POST request fields preceeding the upload file was too large.</Message><MaxPostPreDataLengthBytes>20480</MaxPostPreDataLengthBytes><RequestId>83B08A26C8A163F4</RequestId><HostId>EKI1mI93HBz1uQIdo+gk4aTATLawDTb/hUYGvR/JNtDilyaNSBlMomTWSgYgOloDwFtOReU01RA=</HostId></Error>"
responseCode
:
400
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Uploading objects - Amazon Simple Storage Service
This procedure explains how to upload objects and folders to an S3 bucket using the console. When you upload an object, the object...
Read more >How To Upload File to S3 with the AWS CLI
Learn how to use the AWS CLI tool to upload, download, and synchronize files and folders between local locations and AWS S3 buckets....
Read more >How to Upload Files to AWS S3 with the AWS CLI
When you log in to the AWS portal, navigate to the S3 bucket, choose your required bucket, and download or upload the files....
Read more >How to upload files to AWS S3 - YouTube
Amazon Simple Storage Service (Amazon S3 ) is object storage with a simple web service interface to store and retrieve any amount of...
Read more >AWS S3 Tutorial - How to Create S3 Bucket and Upload Files?
This AWS S3 tutorial explain how to create S3 bucket and upload files. It is a hands-on video, so be ready with your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If like me you are looking to simply upload to a public bucket, here is the code I used that worked: