使用 smithy aws 客户端库失败并缺少区域

问题描述 投票:0回答:1

我将 AWS S3 客户端与 package.json 中的以下 AWS 库结合使用 @aws-sdk/client-s3": "^3.540.0", “@smithy/node-http-handler”:“^2.5.0”

我创建了 S3 客户端属性,如下所示指定它们:

            getAgent(): Agent {
                 const agent = new Agent({
                        rejectUnauthorized: true,
                      });
                return agent;
            } 


           async getClient (): Promise<S3Client> {
               const agent = this.getAgent()
               const endPoint: EndpointV2  = {url: new URL('url')} as EndpointV2 
               const s3Config = {
                region: 'us-west-2',
                endpoint: endPoint,
                credentials: {
                  accessKeyId: 'myKey' ,
                  secretAccessKey: 'mySecret'
                },
               requestHandler:new NodeHttpHandler({
                  httpAgent: agent,
                  httpsAgent: agent
               }),
               retryStrategy: new ConfiguredRetryStrategy(
                   13, 3000
               )
              } 
              const client = new S3Client([s3Config]);
              return client
          }


但是,当我实例化客户端时,出现以下错误

错误就是错误:区域丢失 默认 (/home/app/src/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11) 在/home/app/src/node_modules/@smithy/node-config-provider/dist-cjs/index.js:72:104 在/home/app/src/node_modules/@smithy/property-provider/dist-cjs/index.js:79:33 在异步coalesceProvider(/home/app/src/node_modules/@smithy/property-provider/dist-cjs/index.js:106:18) 在异步/home/app/src/node_modules/@smithy/property-provider/dist-cjs/index.js:117:20 在异步区域(/home/app/src/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30) 在异步/home/app/src/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:89:28 在异步/home/app/src/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:120:14 在异步/home/app/src/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:33:22

该区域清晰存在。仅当我更新应用程序以使用 smithy 库时,此错误才开始出现,因为之前的库已被弃用。请帮忙解决这个问题

node.js amazon-s3
1个回答
0
投票

我的错误,在创建客户端时,我在数组中传递属性 它应该像这样创建 ````
const client = new S3Client(s3Config); 而不是

 const client = new S3Client([s3Config]);


 ```
© www.soinside.com 2019 - 2024. All rights reserved.