javascript - lambda s3.headObject write to dynamodb table -


i new @ lambda , trying develop lambda function grab metadata header s3 object s3.headobject , write dynamodb table (checksum value). cors set expose headers , not working , times out. can tell me what's wrong lambda code? appreciated, in advance!

var aws = require('aws-sdk'); var dynamo = new aws.dynamodb.documentclient({region: 'us-east-1'}); var s3 = new aws.s3();  //specify parameters event write specified db table exports.handler = function(event, context, callback) {   var checksum =       s3.headobject(         {             bucket: unescape(event.records[0].s3.bucket.name),             key: unescape(event.records[0].s3.object.key)         },         function(err, data)         {             if (err)             {                 console.log(err);                 context.done('error', 'error getting s3 object: ' + err);             }             else             {                  return (this.httpresponse.headers['x-amz-meta-checksum']);             }         });      var params = {           item: {             filename: unescape(event.records[0].s3.object.key),             client_checksum : checksum         },         tablename: 's3_log'         };  //write dynammodb dynamo.put(params, function(err, data){         if (err) {             callback(err, null);         }else{             callback(null, data);         }     }); }; 


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -