我一直在努力获取一个节点文件,以便能够处理上传到S3存储桶。到目前为止,我已经能够创建一个存储桶,但是当我使用邮递员运行发布请求时,我似乎无法上传文件。我删除了accessKeyId和秘密accessKey。以前运气好吗?
var S3FS = require("s3fs");
var s3fsImpl = new S3FS('TestBucket12345', {
accessKeyId:"XXXXXXXXXXXXXXXXXXXXXXX",
secretAccessKey:"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
});
s3fsImpl.create();
var multiparty = require("connect-multiparty"),
multipartyMiddleware = multiparty;
module.exports = function(router, passport){
router.use(multipartyMiddleware);
router.post('/fileupload', function(req, res){
var file = req.files.file;
var stream = fs.createReadStream(file.path);
return s3fsImpl.writeFile(file.originalFilename, stream).then(function(){
fs.unlink(file.path, function(err){
if(err){
console.log(err);
}
});
});
});