2012-08-15 111 views
2

更新:在向该用户添加完整访问策略权限后,它从commandline开始工作。现在当我用Node来做时,没有错误,但是我看不到s3文件管理器中的文件。Amazon S3 EPIPE错误

我不断收到使用亚马逊S3服务的EPIPE错误。

我有点卡住,不确定如何继续。

我正在使用Node.js和Knox module

这里是我的代码:

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

好了,所以这是我花了解决这个问题的步骤:

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