有没有办法将 Strapi 媒体上传到 AWS S3 存储桶而不是公共文件夹?

发布于 2025-01-11 20:05:13 字数 743 浏览 4 评论 0原文

我在 Heroku 上托管 Strapi CMS,它的空间有限,因此需要独立于应用程序存储媒体。

为此,我安装了 Strapi-provider-upload-aws-s3 并遵循文档中提供的所有配置步骤,但媒体仍被添加到 public/uploads 文件夹而不是我的 AWS S3 存储桶中,我无法解决为什么。我已经配置了plugins.js、middlewares.js 并更新了我的存储桶策略。

示例plugins.js 和 middleewares.js

AWS 存储桶策略示例

有谁知道我是否需要做其他事情才能使其适用于 Strapi 版本 4.1。 2?

我也尝试了这个 线程< /a> 但我认为解决方案适用于版本 3,因为它们不适合我。

I'm hosting Strapi CMS on Heroku which has a limited amount of space so need to store media independently of the app.

To do this I installed strapi-provider-upload-aws-s3 and followed all of the configuration steps provided in the documentation but media is still being added to the public/uploads folder instead of my AWS S3 bucket and I can’t work out why. I’ve configured plugins.js, middlewares.js and updated my bucket policy.

Example of plugins.js and middleewares.js

Example of AWS bucket policy

Does anyone know if I need to do anything else to get this working for Strapi version 4.1.2?

I've also tried everything on this thread but I think the solutions are for version 3 because they're not working for me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦魇绽荼蘼 2025-01-18 20:05:13

刚刚通过创建一个新的 Strapi 项目让它工作,发现 NPM 指令不正确。您需要将提供程序和提供程序选项包装在 config: {} 中。您还必须使用包的长名称“strapi-provider-upload-aws-s3”

module.exports = ({ env }) => ({
  // ...
  upload: {
    config: {
      provider: 'strapi-provider-upload-aws-s3',
      providerOptions: {
          accessKeyId: 'id',
          secretAccessKey: 'key',
          region:  'eu-west-2',
          params: {
              Bucket: 'Bucket'
          }
      },
    },
  },
  // ...
});``

Just got it working by creating a new Strapi project, and found out that the NPM instructions are incorrect. You need to wrap the provider and provider options in config: {}. You also have to use the package's long name 'strapi-provider-upload-aws-s3'

module.exports = ({ env }) => ({
  // ...
  upload: {
    config: {
      provider: 'strapi-provider-upload-aws-s3',
      providerOptions: {
          accessKeyId: 'id',
          secretAccessKey: 'key',
          region:  'eu-west-2',
          params: {
              Bucket: 'Bucket'
          }
      },
    },
  },
  // ...
});``
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文