I am following this tutorial :
https://devcenter.heroku.com/articles/s3-upload-node
to upload files to Amazon s3 using NodeJS and Jquery. It works fine for small images and files. However it gives a XHR Connection RESET Error.
My CORS Configuration looks exactly like this:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Am I missing something?
if you followed the instructions given in heroku documentation, you'll see a line
const s3Params = {
Bucket: S3_BUCKET,
Key: fileName,
Expires: 60,
ContentType: fileType,
ACL: 'public-read'};
As you can see in this aws documentaion ,the Expires metadata means that the number of seconds to expire the pre-signed URL operation. Here it is given as 60 which equals 1 minute. Uploading large files within the span of 60 sec. is not possible.
FIX:try removing the expire metadata from s3Params or increase the value. By default a presigned url expires in 15 minutes.
Now your code will look like this:
const s3Params = {
Bucket: S3_BUCKET,
Key: fileName,
ContentType: fileType,
ACL: 'public-read'};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With