Amazon S3 EPIPE错误

更新:在向该用户添加完整的访问策略权限之后, 从命令行获取它。 现在,当我用Node来做时,没有错误,但是我看不到s3文件pipe理器中的文件。

我一直使用亚马逊的S3服务获得EPIPE错误。

我有点卡住,不知道如何进行。

我正在使用Node.js和Knox模块 。

这是我的代码:

var client = knox.createClient({ key: amazonAccessKeyId, secret: amazonSecretAccessKey, bucket: amazonBucketName }); function moveFiles() { moveUploadedFile(req.files['aps-file'].path,'/aps-products.csv', this.parallel()); moveUploadedFile(req.files['perry-craft-roof-file'].path,'/perry-craft-roof-products.csv', this.parallel()); res.end('successful!'); } function moveUploadedFile(srcPath, dstPath, callback) { client.putFile(srcPath, dstPath, { 'x-amz-acl': 'public' }, function (err) { if (err) { callback(new Error("Error uploading file for " + dstPath + ": " + err.message), srcPath); console.log(err); return; } console.log('Finished writing file ' + dstPath + ' to Amazon S3 Cloud'); callback(null, srcPath); }); } 

好的,这些是我解决这个问题的步骤:

  1. 安装aws命令行工具,你可以在这里find它: http : //www.timkay.com/aws/
  2. 为我创build的s3用户添加了完全访问(pipe理员访问)策略。
  3. 确保我可以使用以下命令写入该桶: aws put /file/to/put /new-file
  4. 删除{'x-amz-acl': 'public' }它应该是'public-read'否则它不会将文件添加到s3(没有错误)。 请注意{'x-amz-acl': 'private' }也可以。