Sho*_*cks 5 node.js knox-amazon-s3-client
我正在使用knox(https://github.com/LearnBoost/knox)将文件上传到Amazon S3.我刚刚将我的节点应用程序移动到Amazon EC2,并在使用knox上传时出现以下错误.我似乎安装了所有库.nodejitsu上的代码相同.我对node/JS很新,所以我不确定这意味着什么.
/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)
Run Code Online (Sandbox Code Playgroud)
也许,你和我一样,将“mimetype”字符串作为 client.putFile() 函数中的第三个参数传递......
您必须传递一个指定内容类型标头的对象:
client.putFile(localPath, s3Path, {'Content-Type': mimetype} ,function(err, result) {});
Run Code Online (Sandbox Code Playgroud)
或者只是忽略第三个参数(就像我一样):
client.putFile(localPath, s3Path, function(err, result) {});
Run Code Online (Sandbox Code Playgroud)