Strapi Cloud using S3 Upload

System Information
  • Strapi Version: 4.11.1
  • Operating System: Strapi Cloud
  • Database: Strapi Cloud (postgres)
  • Node Version: Strapi Cloud (16.20.0)
  • NPM Version: Strapi Cloud
  • Yarn Version: Strapi Cloud

I am using Strapi Cloud and trying to upload images using the Media Library upload plugin to S3 instead of the hosted instance.

I have set this all up locally using this provider: GitHub - YegorShtonda/strapi-provider-upload-aws-s3-resizing-and-optimisation: Strapi file upload to AWS S3, with resizing and optimisation images, generation webp images

It all works fine locally but when I deploy it using Strapi Cloud, all uploads still go directly to the instance and nothing is sent to S3.

It seems like the plugin configuration in Strapi Cloud is ignored and it forces everything to go to the instance. I have set up the environemnt variables for the bucket, AWS credentials in Strapi Cloud and there are no errors.

All I see are broken images and the URL is to my instance instead of the S3 URL/Cloudfront URL, i.e. https://INSTANCE_ID.media.strapiapp.com/thumbnail_image_hash.jpg.

Does Strapi Cloud work with upload providers or am I doing something wrong?

Looking at the logs, it looks like it is forcing the use of strapi-provider-upload-strapi-cloud

[2023-06-17 06:12:31] │ INFO[0005] RUN ${BUILD_DIR}/scripts/override-application-files.sh &&     ${BUILD_DIR}/scripts/override-application-tracking-uuid.sh &&     ${BUILD_DIR}/scripts/add-dependency.sh "strapi-provider-upload-strapi-cloud" "file:${BUILD_DIR}/overrides/packages/strapi-provider-upload-strapi-cloud" &&     ${BUILD_DIR}/scripts/add-dependency.sh "strapi-provider-email-strapi-cloud" "file:${BUILD_DIR}/overrides/packages/strapi-provider-email-strapi-cloud" &&     ${BUILD_DIR}/scripts/add-dependency.sh "pg" "^8.7.3" &&     ${BUILD_DIR}/scripts/add-dependency.sh "node-fetch" "^2.6.1" 
[2023-06-17 06:12:31] │ INFO[0006] Cmd: /bin/sh                                 
[2023-06-17 06:12:31] │ INFO[0006] Args: [-c ${BUILD_DIR}/scripts/override-application-files.sh &&     ${BUILD_DIR}/scripts/override-application-tracking-uuid.sh &&     ${BUILD_DIR}/scripts/add-dependency.sh "strapi-provider-upload-strapi-cloud" "file:${BUILD_DIR}/overrides/packages/strapi-provider-upload-strapi-cloud" &&     ${BUILD_DIR}/scripts/add-dependency.sh "strapi-provider-email-strapi-cloud" "file:${BUILD_DIR}/overrides/packages/strapi-provider-email-strapi-cloud" &&     ${BUILD_DIR}/scripts/add-dependency.sh "pg" "^8.7.3" &&     ${BUILD_DIR}/scripts/add-dependency.sh "node-fetch" "^2.6.1"] 
[2023-06-17 06:12:31] │ INFO[0006] Running: [/bin/sh -c ${BUILD_DIR}/scripts/override-application-files.sh &&     ${BUILD_DIR}/scripts/override-application-tracking-uuid.sh &&     ${BUILD_DIR}/scripts/add-dependency.sh "strapi-provider-upload-strapi-cloud" "file:${BUILD_DIR}/overrides/packages/strapi-provider-upload-strapi-cloud" &&     ${BUILD_DIR}/scripts/add-dependency.sh "strapi-provider-email-strapi-cloud" "file:${BUILD_DIR}/overrides/packages/strapi-provider-email-strapi-cloud" &&     ${BUILD_DIR}/scripts/add-dependency.sh "pg" "^8.7.3" &&     ${BUILD_DIR}/scripts/add-dependency.sh "node-fetch" "^2.6.1"]

Hi, Jefff,
Can you resolve this problem?

In the end we went with a different hosting provider to host the CMS. We needed to use a different plugin and forcing the Strapi uploader was a deal breaker for us.

I also faced this same issue while integrating Azure Blob storage with the Media Library.

The problem is the configuration which is added in the ./config/plugins.js file

//  ./config/plugins.js
module.exports = ({ env }) =>  ({
  upload: {
    config: {
      provider: "strapi-provider-upload-azure-storage",
      providerOptions: {
        account: env("STORAGE_ACCOUNT"),
        accountKey: env("STORAGE_ACCOUNT_KEY"),
        containerName: env("STORAGE_CONTAINER_NAME"),
        defaultPath: "assets",
      },
    },
  },

});

Strapi will always use the most specific one and has default configurations, so if you do not specify a production environment directory Strapi Cloud will override your configuration when creating it.

The production configuration should be added to the config/env/production/plugins.js file.

//  ./config/env/production/plugins.js
module.exports = ({ env }) =>  ({
  upload: {
    config: {
      provider: "strapi-provider-upload-azure-storage",
      providerOptions: {
        account: env("STORAGE_ACCOUNT"),
        accountKey: env("STORAGE_ACCOUNT_KEY"),
        containerName: env("STORAGE_CONTAINER_NAME"),
        defaultPath: "assets",
      },
    },
  },

});

Even if you make the changes and deploy. It took some time to reflect in the Strapi Cloud(don’t know the reason)