Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

I want to get the link of the file (or file name is also fine) after I uploaded my image to S3. I upload using below code and it worked.

s3Bucket.putObject(data, function(err, data){

        if (err) { 



        } else {





But in the callback data, it has only 1 property, the etag. In the doc it clearly stated it has other objects, so how do I get the path of the uploaded file?

1 Answer

0 votes
by (44.4k points)

You can do that using the S3 URL of the object which got created based on the bucket's name and the params.key property on request data. You can do that within the putObject callback like this:

s3Bucket.putObject(data, function(err, data) {

  var params = this.request.params;

  var region = this.request.httpRequest.region;

  console.log('s3://' + params.Bucket + '/' + params.Key);

  console.log('https://s3-' + region + '' + params.Bucket + '/' + params.Key)


Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer

Browse Categories