Skip to main content

亚马逊 S3 提供商凭证必须在 s3Options 下设置

🌐 Amazon S3 provider credentials must be set under s3Options

Page summary:

在 Strapi 5 中,Amazon S3 上传提供者的选项必须嵌套在一个 s3Options 对象下,凭证应放在一个 credentials 对象中。

🌐 In Strapi 5, the Amazon S3 upload provider options must be nested under an s3Options object, and credentials should be passed inside a credentials object.

在 Strapi 5 中,Amazon S3 提供商(@strapi/provider-upload-aws-s3)使用了 AWS SDK v3,这改变了配置凭证和其他客户端选项的位置。

🌐 In Strapi 5, the Amazon S3 provider (@strapi/provider-upload-aws-s3) uses AWS SDK v3, which changes where credentials and other client options are configured.

此页面是重大更改数据库的一部分,提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

🌐 This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

 Is this breaking change affecting plugins?Yes
 Is this breaking change automatically handled by a codemod?No

重大变更描述​

🌐 Breaking change description

在 Strapi v4 中

像 accessKeyId、secretAccessKey、region 和 params 这样的选项可以直接放在 providerOptions 下,而不需要 s3Options 键。

🌐 Options such as accessKeyId, secretAccessKey, region and params could be passed directly under providerOptions, with no s3Options key.

providerOptions: {
accessKeyId: env('AWS_ACCESS_KEY_ID'),
secretAccessKey: env('AWS_ACCESS_SECRET'),
region: env('AWS_REGION'),
params: {
Bucket: env('AWS_BUCKET'),
},
},

在 Strapi 5 中

这些选项必须嵌套在一个 s3Options 对象中,凭证应该封装在一个 credentials 对象里。在 s3Options 根目录放 accessKeyId/secretAccessKey 依然可以,但会触发弃用警告。

🌐 Those options must be nested inside an s3Options object, and credentials should be wrapped in a credentials object. Placing accessKeyId/secretAccessKey at the root of s3Options still works but triggers a deprecation warning.

providerOptions: {
s3Options: {
credentials: {
accessKeyId: env('AWS_ACCESS_KEY_ID'),
secretAccessKey: env('AWS_ACCESS_SECRET'),
},
region: env('AWS_REGION'),
params: {
Bucket: env('AWS_BUCKET'),
},
},
},

迁移​

🌐 Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

🌐 This section regroups useful notes and procedures about the introduced breaking change.

注意​

🌐 Notes

手动操作​

🌐 Manual procedure

如果你正在将 Strapi v4 的 Amazon S3 配置升级:

🌐 If you are upgrading an Amazon S3 configuration from Strapi v4:

  1. 将 accessKeyId、secretAccessKey、region、params(以及任何其他 S3 客户端选项)嵌套在 s3Options 对象的 providerOptions 下。
  2. 把 accessKeyId 和 secretAccessKey 移到 s3Options 里的 credentials 对象中。把它们留在 s3Options 的根目录下仍然可以用,但已经被弃用,会触发警告。