使用node生成预签名url的代码有什么问题?

时间:2019-07-29 09:04:43

标签: node.js aws-sdk

此API生成的预签名网址有问题。 当我使用邮递员上传带有图像的图像时显示错误

“我们计算出的请求签名与您提供的签名不匹配。请检查您的密钥和签名方法。” 我的代码有什么问题?

const _ = require('lodash'),
statusCode = require('../../../lib/statusCode'),
AWS = require('aws-sdk'),
config = require('config');
AWS.config.update({ accessKeyId: config.get('AWS.accessKeyId'), 
secretAccessKey: config.get('AWS.secretAccessKey') });

const s3 = new AWS.S3();

class Queries {

static async imageUpload() {

    // var s3 = new AWS.S3(); 
    try {
        const params = { Bucket: 'firelabs', Key: 'jpegsystems- 
  home.jpg' , ACL: 'bucket-owner-full-control', 
    ContentType:'image/jpeg' };
        const url = await s3.getSignedUrl('putObject', params);
        console.log(url);
        return url;
    }
    catch (e) {
        throw e;
    }
}
}
   module.exports = Queries;

0 个答案:

没有答案