更新:在向该用户添加完全访问策略权限后,它可以从命令行工作。现在,当我使用 Node 执行此操作时,没有错误,但我在 s3 文件管理器中看不到文件。
使用 Amazon 的 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);
});
}