问题
UPDATE: got it working from the commandline after add a full access policy permissions to that user. Now when I do it with Node there is no error but I can't see the files in my s3 file manager.
I keep getting an EPIPE error using Amazon's S3 service.
I am a little stuck and unsure of how to proceed.
I am using Node.js with the Knox module.
Here is my code:
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:
Ok so these are the steps I took to resolve this problem:
- Installed aws commandline tool you can find it here: http://www.timkay.com/aws/
- Added a Full Access (Administrator Access) policy to the s3 user I created.
- Made sure I can write to that bucket using the command:
aws put /file/to/put /new-file. - Removed
{'x-amz-acl': 'public' }it should be'public-read'otherwise it will not add the files to s3 (without errors). Note that{'x-amz-acl': 'private' }works too.
来源:https://stackoverflow.com/questions/11978672/amazon-s3-epipe-error