'How to get s3 url in Nodejs?

I uploaded a file on s3. Now I want to get the s3 url of that file in Nodejs. The url should have format "s3://Bucket-name/filename.txt"

i tried s3.getSignedUrl() but it returned a https url.



Solution 1:[1]

You can use the s3.upload method just like this

var params = {Bucket: 'bucket', Key: 'key', Body: stream};
var options = {partSize: 10 * 1024 * 1024, queueSize: 1};
s3.upload(params, options, function(err, data) {
  console.log(err, data);
});

once you do that you can fetch the URL of the uploaded file by

`data.Location`

Aws Docs for data.Location ( check callback parameters )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jatin Mehrotra