2014-09-02 36 views
5

我正在使用knox(https://github.com/LearnBoost/knox)将文件上传到Amazon S3。我刚刚将我的节点应用程序移至Amazon EC2,并且在使用knox上传时出现以下错误。我似乎已经安装了所有的库。 nodejitsu上的代码相同。我对node/JS很新,所以我不确定这是什么意思。TypeError:使用knox上传非对象时调用的Object.keys

/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) 

回答

1

也许,你和我一样,都经过“MIME类型”字符串作为第三个参数中client.putFile()函数...

你必须通过一个对象指定内容类型头:

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

,或者直接忽略第三个参数(像我一样):

client.putFile(localPath, s3Path, function(err, result) {}); 
相关问题