TypeError: Object.keys thrown by a non-object when loaded with knox

I am using knox ( https://github.com/LearnBoost/knox ) to upload the file to Amazon S3. I just migrated my node application to Amazon EC2 and have the following error while loading using knox. It seems that I have all the libraries installed. The same code was OK on nodejitsu. I am completely new to node / JS, so I'm not sure what that means.

/home/ec2-user/foo/node_modules/knox/lib/auth.js:208 Object.keys(url.query).forEach(function (key) { ^ TypeError: Object.keys called on non-object at Function.keys (native) at Object.exports.canonicalizeResource (/home/ec2-user/foo/node_modules/knox/lib/auth.js:208:10) at Client.request (/home/ec2-user/foo/node_modules/knox/lib/client.js:275:22) at Client.put (/home/ec2-user/foo/node_modules/knox/lib/client.js:326:15) at Client.putStream (/home/ec2-user/foo/node_modules/knox/lib/client.js:408:18) at /home/ec2-user/foo/node_modules/knox/lib/client.js:378:20 at Object.oncomplete (fs.js:93:15) 
+5
source share
1 answer

Perhaps you, like me, passed the string "mimetype" as the third parameter in the client.putFile () function ...

You must pass an object defining the headers of the content type:

 client.putFile(localPath, s3Path, {'Content-Type': mimetype} ,function(err, result) {}); 

or just ignore the third parameter (for example, I did):

 client.putFile(localPath, s3Path, function(err, result) {}); 
+1
source

Source: https://habr.com/ru/post/1201631/


All Articles