zoomoid / strapi-provider-upload-aws-s3-advanced

A partial fork of https://github.com/strapi/strapi to extend the S3 Upload Provider to support path prefixes inside a bucket
MIT License
26 stars 23 forks source link

Not recognized by strapi version 4 #1

Closed aaronclimbs closed 2 years ago

aaronclimbs commented 2 years ago

I can't tell from the README/versioning if this is expected to work with the most recent version of Strapi, but when I've set this up as below, it doesn't seem as though Strapi is even recognizing the plugin:

module.exports = ({ env }) => ({
  // ...
  upload: {
    provider: "aws-s3-advanced",
    providerOptions: {
      accessKeyId: env("STRAPI_AWS_ACCESS_KEY_ID"),
      secretAccessKey: env("STRAPI_AWS_ACCESS_SECRET"),
      region: env("STRAPI_AWS_REGION"),
      params: {
        Bucket: env("STRAPI_AWS_BUCKET"),
      },
      baseUrl: env("CF_BASE_URL"), // e.g. https://cdn.example.com, this is stored in strapi's database to point to the file
      prefix: env("STRAPI_AWS_BUCKET_PREFIX"), // e.g. strapi-assets, note the missing slash at the start
    },
  },
// ...
})

I've changed the env variables to ones that do not exist and no errors are thrown, which leads me to believe that the config itself is not being read by strapi.

When I added a config: {... } wrapper around everything within the upload block, so that I could put enabled: true in the upper block

  upload: {
    enabled: true,
    config: {
      provider: "aws-s3-advanced",
      providerOptions: {
        accessKeyId: env("STRAPI_AWS_ACCESS_KEY_ID"),
        secretAccessKey: env("STRAPI_AWS_ACCESS_SECRET"),
        region: env("STRAPI_AWS_REGION"),
        params: {
          Bucket: env("STRAPI_AWS_BUCKET"),
        },
        baseUrl: env("CF_BASE_URL"), // e.g. https://cdn.example.com, this is stored in strapi's database to point to the file
        prefix: env("STRAPI_AWS_BUCKET_PREFIX"), // e.g. strapi-assets, note the missing slash at the start
      },
    },
  },

it did throw the below:

[2021-12-22 18:07:09.846] error: Could not load upload provider "aws-s3-advanced".
zoomoid commented 2 years ago

Sorry, yeah the versioning isn't converged with strapi, I upgraded to v4.0.0 because of changes for the AWS SDK used. I haven't found the time to experiment with strapi v4 properly yet, what I've seen from it is that they changed their entire API regarding plugins without providing stable documentation (at least this was the case 2 weeks ago).

Thank you for the pull request, will merge this as soon as I have created a strapi v4 playground.

aaronclimbs commented 2 years ago

No problem - I just wanted you to know that it worked with the current code without going through their plugin migration guide tutorial using codemods and lots of manual checks. The only changes I needed to get it working are those listed in the PR. Hopefully that makes it easier once you get that playground set up.

Thanks for your work on this!

zoomoid commented 2 years ago

I will go ahead and bump the package version as soon as your changes make it to the main branch 👍