我无法将庞大的图像上传到s3存储桶 我已经尝试过了
var s3Bucket = new AWS.S3({
params: {
Bucket: 'name_2'
}
});
s3Bucket.createBucket(function() {
buf = new Buffer(req.body.imageBinary.replace(/^data:image\/\w+;base64,/, ""), 'base64')
var params = {
Key: 'upload/' + req.body.user_id,
Body: buf,
ContentEncoding: 'base64',
ContentType: 'image/jpeg',
ACL: 'public-read'
};
s3Bucket.upload(params, function(error, aws_images) {
if (error) return next(error);
db.query('UPDATE users set img= $2 where "_id" = $1 RETURNING *', [req.body.user_id, aws_images.Location], function(err, result) {
if (err) return next(err);
return res.status(200).send({
status: "user profile picture added successfully",
data: result.rows
})
})
})
})
上面的代码对于50 KB以内但不超过50 KB的图像/文件效果很好。我应该提到任何限制吗?