Situation
You want to upload a file to S3 with Axios and the PUT
method.
Challenge
S3 needs a Content-Length for PUT
requests, otherwise it throws an 501.
Solution
Upload the file as a stream and pass the size as header.
1 | await axios.put(s3_upload_url, fs.createReadStream(filename), { |
Like what you read?
You can hire me or make a donation via PayPal!