媒体库提供商
🌐 Media Library providers
Page summary:媒体库提供商扩展了 Strapi 的上传功能,以将文件存储在像 AWS S3 或 Cloudinary 这样的外部服务中。你可以安装官方提供商,在
/config/plugins中配置它们,创建自定义提供商,或使用带签名 URL 的私有提供商来安全访问资源。🌐 Media Library providers extend Strapi's upload capabilities to store files in external services like AWS S3 or Cloudinary. You can install official providers, configure them in
/config/plugins, create custom providers, or set up private providers with signed URLs for secure asset access.
媒体库 功能由一个名为 Upload 的后端服务器包提供支持,该包利用了提供程序的使用。
🌐 The Media Library feature is powered by a back-end server package called Upload which leverages the use of providers.
默认情况下,Strapi 提供了一个提供程序,可以将文件上传到 Strapi 项目中的本地 public/uploads/ 目录。还可以使用其他提供程序,这些提供程序为插件的核心功能添加了扩展。使用它们可以将文件上传到其他位置,例如 AWS S3 或 Cloudinary。
🌐 By default Strapi provides a provider that uploads files to a local public/uploads/ directory in your Strapi project. Additional providers are available and add an extension to the core capabilities of the plugin. Use them to upload your files to another location, such as AWS S3 or Cloudinary.
Strapi 维护着官方提供者,可以通过 Marketplace发现。社区维护的提供者也可以通过 npm获得。
可以将提供者配置为私有,以确保资源 URL 会被签名以实现安全访问。
🌐 A provider can be configured to be private to ensure asset URLs will be signed for secure access.
安装提供程序
🌐 Installing providers
可以使用 NPM 或 Yarn 安装新提供者,使用以下格式 @strapi/provider-<plugin>-<provider> --save。
例如,要为媒体库功能安装 AWS S3 提供程序:
🌐 For example, to install the AWS S3 provider for the Media Library feature:
- Yarn
- NPM
yarn add @strapi/provider-upload-aws-s3
npm install @strapi/provider-upload-aws-s3 --save
配置提供者
🌐 Configuring providers
新安装的提供程序已在 “/config/plugins” 文件 中启用并配置。如果该文件不存在,请先创建它。
🌐 Newly installed providers are enabled and configured in the /config/plugins file. If this file does not exist, create it first.
每个提供商都会有不同的配置设置。请查看下面专门页面上 Strapi 维护的提供商的相应条目,或者查看该提供商的 Marketplace 页面。
Strapi 维护的提供者如下。点击卡片将重定向到带有配置示例的文档页面:
🌐 The providers maintained by Strapi are the following. Clicking on a card will redirect you to a docs page with a configuration example: