ChrisRich ChrisRich - 1 month ago 9x
Node.js Question

Upload file to Amazon S3 using HTTP PUT

I work in a financial institution and for security reasons my employer cannot give out the

access key id
and the
access key secret
to the AWS account. This means I can't use aws-sdk.

As a next option, would it be possible to upload files using HTTP PUT to a public S3 bucket without using the AWS-SDK that requires the
access key id
and the
access key secret

I had a look at this answer: How to upload a file using a rest client for node

And was thinking of this approach:

var request = require('request');

var options = {
method: 'PUT',
preambleCRLF: true,
postambleCRLF: true,
uri: '',
multipart: [
'content-type': 'application/pdf'
body: fs.createReadStream('/uploads/uploaded-file.pdf')

request(options, function(err, response, body){

return console.log(err);

console.log('File uploaded to s3');

Could that work?


Your above code works only if you have custom storage(that too it should be public) and not for AWS storage.

For AWS storage access key id and the access key secret is mandatory, without these you cannot upload the files to storage