I am uploading videos directly to a AWS S3 bucket, but the uploads seem slow for even a 10 second iPhone video. A user on my website uploads a video.
Step 1: Create createPresignedPost on server
const AWS = require('aws-sdk');
s3 = new AWS.S3({apiVersion: '2006-03-01'});
AWS.config.update({keys, region});
var params = {
Bucket: 'bucket',
Fields: {
key: fileNameKey
},
Expires: expireTime,
Conditions: [
["content-length-range", 0, 500000000], // limit to 500 Mb
[ "eq", "$acl", "public-read" ]
]
};
This works fine, I send the presignedPostUrl back to user browser, then the user uploads a file from the browser. Step 2:
let config = { headers: { 'Content-Type': 'multipart/form-data' } };
await axios.post(presignedPostUrl, formData, config)
And the video uploads fine, it's just slow. 26 seconds for a 60-second video. I tried enabled AWS s3 Transfer acceleration in the AWS console, and then I initialize it when I create my presignedPostUrl in step 1:
s3 = new AWS.S3({useAccelerateEndpoint: true, apiVersion: '2006-03-01'});
Video uploads, but it's about the same speed as the original upload. 60 second iPhone video takes 30 seconds to upload.
Am I setting this up correctly? Would it be faster to upload using Cloudfront?