Home > database >  Is there a way to upload Strapi media to AWS S3 bucket instead of public folder?
Is there a way to upload Strapi media to AWS S3 bucket instead of public folder?

Time:03-08

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.

CodePudding user response:

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'
          }
      },
    },
  },
  // ...
});``
  • Related