Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: v5 ready + s3 private buckets support #21

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Zharkan
Copy link

@Zharkan Zharkan commented Sep 29, 2024

Fix: #20

@Zharkan
Copy link
Author

Zharkan commented Jan 11, 2025

@WalkingPizza Can you take a look when you've got enough time please, it can fix : #20

@dmitrysmagin
Copy link

One more tweak for this pull request.
I've tested v5 version locally and found out that this file https://github.com/Gaylord-Julien/strapi-plugin-placeholder/blob/v5/server/src/pluginId.ts should have a different name:

export const PLUGIN_ID = 'placeholder';

Otherwise this piece of code fails to find the service (https://github.com/Gaylord-Julien/strapi-plugin-placeholder/blob/v5/server/src/utils.ts):

const getService = <ServiceName extends keyof PluginServices>(
  strapi: Core.Strapi,
  serviceName: ServiceName
): PluginServices[ServiceName] => {
  return strapi.plugin(PLUGIN_ID).service(serviceName); // <-- this will fail
};

@dmitrysmagin
Copy link

Also, changes for private buckets are questionable. In my project I had to revert to original code which uses the current provider for the uploads:

const placeholder = ({ strapi }: { strapi: Core.Strapi }) => {
  return {
    async generate(url: string): Promise<string | null> {
      try {
        const settings = getService(strapi, 'settings').get();
        const { base64 } = await getPlaiceholder(url, settings);
        return base64;
      } catch (error) {
        strapi.log.error(error);
        return null;
      }
    },
  };
};

The code above is sufficient. Tried both with local provider and AWS S3 configured for the Media Library - it works, no need for additional S3 handling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strapi 5
2 participants