当前位置: 首页 > 面试题库 >

当我尝试向我的S3存储桶(Node.js)发送内容时,AWS缺少凭据

赏梓
2023-03-14
问题内容

嘿!

从昨天开始我就遇到了这个问题,我在寻找解决方案时遇到了麻烦。

我正在尝试向我的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',
     code: 'CredentialsError',
     errno: 'Unknown system errno 64',
     syscall: 'connect',
     time: Thu Oct 09 2014 14:03:56 GMT-0300 (BRT),
     originalError: 
      { code: 'Unknown system errno 64',
        errno: 'Unknown system errno 64',
        syscall: 'connect',
        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. 
}); // 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");
    }
});

这里的好资源



 类似资料:
  • 如果我能知道根本原因是什么就好了。

  • 我正在尝试配置我的云端分发,以将mydomain.com请求路由到S3存储桶,并将mydomain.com/api/*请求路由到ELB。 在53号公路上,我有dev.mydomain.com指向云端分布,有别名记录 route53中云端的别名 我在云前线中配置了两个源 - 一个到 S3,另一个到可公开访问的 ELB Cloudfront起源设置 我已经配置了一个(在默认的基础上)行为来将api/*

  • 问题内容: 我正在尝试在AWS ECS上设置Jenkins服务器,但是我必须发出将S3挂载到我的Docker容器的信息。 谁能为我提供可以在ECS服务中安装s3存储桶的任务定义?soi可以将我的Jenkins工作区存储在s3上 问题答案: 您可以在EC2实例中安装s3fs(或者可以将自定义AMI用于ECS群集)。将S3存储桶安装在EC2实例中,然后您就可以始终共享主机路径。

  • 我确实创建了一个lambda函数,当文件在S3存储桶中上传时,它应该将数据上传到DynamoDB。但是,当文件在存储桶中上传时,我在CloudWatch中得到一个“GetObject操作:权限拒绝”。lambda函数附加了一个IAM角色,并带有这些策略:Amazon onlambdaFullAccess、Amazon onS3FullAccess、Amazon onCloudWatchLogsFu

  • 我知道这个问题在这里已经被问了无数次了,我已经搜索了SO和其他来源来寻找解决方法,但我就是无法解决这个错误。我的ClientPlayer类属性有一个getter和setter,当某个按钮被调用时setter在GUI中被调用,我希望在客户端连接对象并将对象发送到服务器后使用getter。调用方法“This.client.SendTCP(ClientPlayer.GetPlayerName());”返

  • 问题内容: 我这样做是读取了S3存储桶中的文件名 现在,我需要获取文件的实际内容,类似于。什么是最好的方法? 问题答案: boto3提供了一种资源模型,该资源模型使诸如迭代对象之类的任务变得更加容易。不幸的是,StreamingBody不提供或。