如何通过邮递员将图像上传到AWS S3

时间:2017-11-29 12:12:58

标签: node.js amazon-web-services postman

function uploadPinMedia(req, res, next) {
    console.log(req.file);
    
    var s3 = new AWS.S3({
        params: {
            Bucket: 'mapery-v2'
        }
    })
    AWS.config.update({
        accessKeyId: 'xxxxxxxxxxxxxxxxxxxx',
        secretAccessKey: 'xxxxxxxxx+xxxxxxxxxxxxxxxxxxxxx/xxxxxxxx',
        
    });
    var file = req.file;
    
    s3.upload({
        ACL: 'public-read',
        Body: fs.createReadStream(req.file),
        Key: 'upload-v2',

    }, (err, media_res) => {
        console.log(err, media_res)

    });
}

我正在尝试通过邮递员将图片上传到s3存储桶,但它给了我一个像TypeError: path must be string or buffer这样的错误。怎么解决这个?

0 个答案:

没有答案