0 votes
1 view
in AWS by (19.2k 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.6k 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 + '.amazonaws.com/' + params.Bucket + '/' + params.Key)


Welcome to Intellipaat Community. Get your technical queries answered by top developers !