AWS Missing credentials when i try send something to my S3 Bucket (Node.js)

后端 未结 7 894
眼角桃花
眼角桃花 2020-12-02 16:51

Hei!

I\'m having this issue since yesterday, and I\'m having trouble for find a solution.

I\'m trying to send somethings to my S3 bucket, but this message ap

7条回答
  •  执笔经年
    2020-12-02 17:24

    Try hardcoding your params and see if you get the error again :

    AWS.config.update({
        accessKeyId: "YOURKEY",
        secretAccessKey: "YOURSECRET",
        "region": "sa-east-1"   <- If you want send something to your bucket, you need take off this settings, because the S3 are global. 
    }); // for simplicity. In prod, use loadConfigFromFile, or env variables
    
    var s3 = new AWS.S3();
    var params = {
        Bucket: 'makersquest',
        Key: 'mykey.txt',
        Body: "HelloWorld"
    };
    s3.putObject(params, function (err, res) {
        if (perr) {
            console.log("Error uploading data: ", err);
        } else {
            console.log("Successfully uploaded data to myBucket/myKey");
        }
    });
    

    Good resource here

提交回复
热议问题