Strapi upload provider contabo

I need to use contabo object storage it uses the same as aws s3 . is there easy way to do the integration ? is there plugin I can use to do the integration for the upload provider with contabo object storage ?

Contabo doesn’t have a plugin unfortunately so you have to write it from scratch.
It’s not too hard tho, you can look up the AWS S3 plugin’s source code and write your own based on that.

This is true, I use Contabo as my host actually didn’t know they had OBstorage too :smiley:

But when it comes to write a plugin, they are saying S3-Compatible API so I presume URLs etc are the only thing that changes.
Might be worth check that it has an API you can use if so what are the docs, and could write a plugin for it.

I wrote a plugin for S3 myself so as @DavidWitten said it should not be to hard to modify it.

yeah Thanks guys I found the solution it is very easy . Use Contabo Object Storage with NodeJS - DEV Community . using this tutorial and I used the official aws provider upload by strapi team just changed the plugin.js files added endpoint and s3endpointbucket and it worked .

const s3 = new AWS.S3({
    endpoint: `contabo_storage_bucket_url`, // e.g. https://eu2.contabostorage.com/bucketname
    accessKeyId: "your_access_key_here",
    secretAccessKey: "your_secret_key_here",
    s3BucketEndpoint: true,
});
3 Likes

what did you change in the plugin.js files added endpoint ? Is it still working ?

I know this thread is a bit old, but how do you add the contentSecurityPolicy for Contabo in middlewares.ts?

I tried this, but it didn’t work:

{
    name: "strapi::security",
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          "connect-src": ["'self'", "https:"],
          "img-src": [
            "'self'",
            "data:",
            "blob:",
            `${env("CONTABO_OBJECT_STORAGE_ENDPOINT")}`,
          ],
          "media-src": [
            "'self'",
            "data:",
            "blob:",
            `${env("CONTABO_OBJECT_STORAGE_ENDPOINT")}`,
          ],
          upgradeInsecureRequests: null,
        },
      },
    },
  },

as for this question - the config in plugins.ts for me looks like this:

upload: {
    config: {
      provider: "aws-s3",
      providerOptions: {
        credentials: {
          accessKeyId: env("CONTABO_OBJECT_STORAGE_ACCESS_KEY"),
          secretAccessKey: env("CONTABO_OBJECT_STORAGE_SECRET_KEY"),
        },
        endpoint: env("CONTABO_OBJECT_STORAGE_ENDPOINT"),
        forcePathStyle: true,
        region: "default",
        params: {
          Bucket: env("CONTABO_OBJECT_STORAGE_BUCKET"),
        },
      },
    },
  },

You have to remember about: forcePathStyle: true, because @strapi/provider-upload-aws-s3 uses @aws-sdk version 3, not 2