0

I am using aws-sdk and exif library to get image details from images in an s3 bucket.

I have used to get exif images details of my buckets of aws s3 images in node.js. For that used aws-sdk and exif library for get all data of my aws bucket,but i have not get result of that code.
I have used following code :

app.get('/getContents', function(req,res){
    var params = {Bucket: req.query.Bucket};

    return new Promise(function(resolve, reject) {
        s3.listObjects(params, function(err, data) {
           if (err) {
                var error = {};
                error['isError'] = true,
                error['status'] = 400,
                error['message'] = "Data Not Found",
                error['data'] = err
                resolve(error);
            }
            else {
                var result1 = [];   
                var result = data.Contents;
                result.forEach(function(final){
                    var urlParams = {Bucket: req.query.Bucket, Key: final.Key};
                    s3.getSignedUrl('getObject', urlParams, function(err, url){
                        request.get(url, function (err, result, body) {
                            var path = result.request.uri.href;
                            new ExifImage(body, function (error, exifData) {
                                if (error) {
                                    result1.push(error.message);
                                }
                                else {
                                    result1.push(exifData);
                                    res.send(result1);
                                }
                            });
                        });
                    });
                });     
                //res.send(result1);
            }   
        }); 
    });
});

but response is null in the browser. How can find that details for this code:

Will
  • 2,163
  • 1
  • 22
  • 22
  • So, there's lots of points in your code where an error could occur, and the response would just be dropped. Make sure you're using `res` to communicate with the browser when handling errors. What happens when you uncomment the `res.send(result1)` line near the end? – Will Dec 05 '17 at 17:01
  • When i uncomment the res.send(result1) line near the end response will bwe null in the browser –  Dec 06 '17 at 05:34

1 Answers1

0

I found that solution in github issues .... this is solution for that https://github.com/nathan818fr/async-loop/issues/2