Images not uploading to AWS

System Information
  • Strapi Version: 3.6.5
  • Operating System: MAC
  • Database: postgres
  • **Node Version **: v12.14.0
  • NPM Version: 6.13.4
  • Yarn Version:

Hi I have been stuck for days. I have deployed my site on Heroku, it builds successfully however when I add images to the media library, the image is uploaded, thumbnail is shown but the AWS bucket is empty. The AWS bucket is public, I even done a test using postman, the images were uploaded fine. PLEASE HELP! IM PULLING MY HAIR OUT

Here are my files

./config/database.js

const parse = require(‘pg-connection-string’).parse;

module.exports = ({ env }) => {

if(env(‘NODE_ENV’) === ‘production’) {
const config = parse(process.env.DATABASE_URL)
return {
defaultConnection: ‘default’,

  connections: {
    default: {
      connector: 'bookshelf',
      settings: {
        client: 'postgres',
        host: config.host,
        port: config.port,
        database: config.database,
        username: config.user,
        password: config.password,
        ssl: {
          rejectUnauthorized: false,
        },
      }, 
      options: {
        ssl: false
      },
    }
  }
}

}
return {
defaultConnection: ‘default’,
connections: {
default: {
connector: ‘bookshelf’,
settings: {
client: ‘sqlite’,
filename: env(‘DATABASE_FILENAME’, ‘.tmp/data.db’),
},
options: {
useNullAsDefault: true,
},
},
},
}
};

.config/middlewares.js

module.exports = [
//
{
name: ‘strapi::security’,
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
‘connect-src’: ["‘self’", ‘https:’],
‘img-src’: ["‘self’", ‘data:’, ‘blob:’, ‘bucketname.s3.eu-west-2.amazonaws.com’],
‘media-src’: ["‘self’", ‘data:’, ‘blob:’, ‘bucketname.s3.eu-west-2.amazonaws.com’],
upgradeInsecureRequests: null,
},
},
},
},
//
];

.config/plugins.js

module.exports = ({ env }) => {

if(env(‘NODE_ENV’) === ‘production’) {
return {
upload: {
config: {
provider: ‘strapi-provider-upload-aws-s3’,
providerOptions: {
accessKeyId: env(‘AWS_ACCESS_KEY_ID’),
secretAccessKey: env(‘AWS_ACCESS_SECRET’),
region: env(‘AWS_REGION’),
params: {
Bucket: env(‘AWS_BUCKET’)
}
}
}
}
}
}

return {

}
}

.env

HOST=0.0.0.0
PORT=1337
STRIPE_SK=*****

DATABASE_URL=postgres://j*********

AWS_ACCESS_KEY_ID=A***********************
AWS_ACCESS_SECRET=T**********************
AWS_REGION=eu-west-2
AWS_BUCKET=bucketname