Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 使用Contigo IdentityPoolId访问未经身份验证的AWS S3,错误:CredentialsError:配置中缺少凭据_Amazon Web Services_Amazon S3_Aws Sdk - Fatal编程技术网

Amazon web services 使用Contigo IdentityPoolId访问未经身份验证的AWS S3,错误:CredentialsError:配置中缺少凭据

Amazon web services 使用Contigo IdentityPoolId访问未经身份验证的AWS S3,错误:CredentialsError:配置中缺少凭据,amazon-web-services,amazon-s3,aws-sdk,Amazon Web Services,Amazon S3,Aws Sdk,我正在尝试通过Angular应用程序设置与S3的连接 我是这样做的: 创建标识池 配置角色权限 配置CORS 定义网页 将SDK添加到浏览器脚本中 <script src="https://sdk.amazonaws.com/js/aws-sdk-2.728.0.min.js"></script> 当我运行此命令时: s3.listObjects({ Delimiter: '/' }, (err, data) => { if (

我正在尝试通过Angular应用程序设置与S3的连接

我是这样做的:

  • 创建标识池
  • 配置角色权限
  • 配置CORS
  • 定义网页
  • 将SDK添加到浏览器脚本中

    <script src="https://sdk.amazonaws.com/js/aws-sdk-2.728.0.min.js"></script>
    
    当我运行此命令时:

      s3.listObjects({ Delimiter: '/' }, (err, data) => {
          if (err) {
            console.log("Error", err);
          } else {
            console.log("Success", data.Buckets);
          }
        });
    
    我在AWS控制台中看到有一个连接:

    但是仍然会得到错误:
    error credentials错误:配置中缺少凭据,如果使用AWS\u config\u文件,请将AWS\u SDK\u LOAD\u config=1

    消息:“标识池配置无效。请检查为此池分配的IAM角色。”\u键入:“InvalidIdentityPoolConfigurationException”

    我错过了什么?我想,
    IdentityPoolId
    就是所需要的一切

    const AWS = (window as any).AWS;
    AWS.config.region = 'eu-west-1'; // Region
    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
      IdentityPoolId: 'eu-west-1:bla-bla-bla',
    });
    
    const s3 = new AWS.S3({
      apiVersion: '2006-03-01',
      params: { Bucket: 'my-bucket' }
    });
    
      s3.listObjects({ Delimiter: '/' }, (err, data) => {
          if (err) {
            console.log("Error", err);
          } else {
            console.log("Success", data.Buckets);
          }
        });