fix: v5 ready + s3 private buckets support
Fix: https://github.com/WalkingPizza/strapi-plugin-placeholder/issues/20
@WalkingPizza Can you take a look when you've got enough time please, it can fix : https://github.com/WalkingPizza/strapi-plugin-placeholder/issues/20
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
};
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
@WalkingPizza can you merge this please?
@WalkingPizza - can you please merge this release and make a new version? Or let me know how I can do this?