Node.js   发布时间:2022-04-24  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了AWS当我尝试发送一些东西到我的S3 Bucket(Node.js)时缺少凭据大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
喜!

自昨天以来我遇到了这个问题,找到解决方案我遇到麻烦。

我试图将某些东西发送到我的S3桶,但是当我尝试:这个消息出现在我的控制台中

{ [CredentialsError: Missing credentials in config]
  message: 'Missing credentials in config',code: 'CredentialsError',errno: 'UnkNown system errno 64',syscall: 'connect',time: Thu Oct 09 2014 14:03:56 GMT-0300 (BRT),originalError: 
   { message: 'Could not load credentials from any providers',originalError: 
      { code: 'UnkNown system errno 64',message: 'connect UnkNown system errno 64' } } }

这是我的代码

var s3 = new AWs.S3();
AWs.config.loadFromPath('./AwsConfig.json'); 

    s3.putObject(params,function(err) {
        if(err) {
            console.log(err);
        }
        else {
            console.log("succes");
        }
});

证书是正确的。有人知道可以吗?我搜索但我找不到任解决方案。

我的凭证(假):

{
    "accessKeyId": "BLALBLALBLALLBLALB","secretAccessKey": "BLABLALBLALBLALBLLALBLALLBLALB","region": "sa-east-1","apiVersions": {
      "s3": "2006-03-01","ses": "2010-12-01"
    }
}

编辑:

有关帮助,所有的代码

var fs = require('fs');
var AWS = require('aws-sdk');


var s3 = new AWs.S3();
AWs.config.loadFromPath('./MYPATH.json'); //this is my path to the aws credentials.


var params = {
        Bucket: 'tesTing-dev-2222',Key: file,Body: fs.createReadStream(filE)
    };

s3.putObject(params,function(err) {
    if(err) {
        console.log(err);
    }
    else {
        console.log("success");
    }
});

错误

Error uploading data:  { [PeRMANentRedirect: The bucket you are attempTing to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.]
  message: 'The bucket you are attempTing to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.',code: 'PeRMANentRedirect',time: Thu Oct 09 2014 14:50:02 GMT-0300 (BRT),statusCode: 301,retryable: false }

解决方法

尝试硬编码你的参数,看看你是否再次收到错误

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. 
});

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

大佬总结

以上是大佬教程为你收集整理的AWS当我尝试发送一些东西到我的S3 Bucket(Node.js)时缺少凭据全部内容,希望文章能够帮你解决AWS当我尝试发送一些东西到我的S3 Bucket(Node.js)时缺少凭据所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。