bymayo / craft-pdf-transform

Transform a PDF page to an image (JPEG, PNG)
MIT License
12 stars 9 forks source link

Craft 3: file_get_contents() cannot be empty error - for volumes without public URLs #22

Open Christopholus opened 1 year ago

Christopholus commented 1 year ago

A website of ours has the requirement of hosting PDFs that are gated and not accessible to the public. These PDFs are housed in volumes with no public URLs, meaning they are only reachable through a serverside process.

In the CraftCMS backend, we have the "assets in this volume have public URLs" toggled off: image

Unfortunately any new assets being uploaded to these directories are failing to generate thumbnails (either on upload, or at runtime if the "Transform on upload" setting is disabled.), with the following error: image

PDF Thumbnails for volumes with public URLs appear to be generating without issue, and when I turn on Public URLs for this gated volume - the plugin works as intended.

My hunch is that the plugin may be looking at the public URL path to find the PDF for thumbnail generation. If this is the case, a possible fix might be modifying the logic to instead look at the required "File System Path" to locate the PDF for transformation.

Lastly I will add that we currently have 100+ gated PDFs with thumbnails (most from earlier last year) which leads me to believe this issue may be related to one of the more recent plugin updates - but I could be incorrect!

Thank you in advance for any help you can provide!

bymayo commented 1 year ago

@Christopholus Can you confirm which version your using of Craft and the plugin? My main reason for asking is because on the latest versions of the plugin I changed it from using url to path to get the PDF's and transform them.

Christopholus commented 1 year ago

Hey @bymayo - thanks for the reply!

Here are the versions we're on: CraftCMS: 3.7.61 PDF Transform: 1.0.9

If it's helpful at all, after some tracing I believe this is the line that's throwing the error in this scenario: https://github.com/bymayo/craft-pdf-transform/blob/craft-3/src/services/PdfTransformService.php#L115

Looking forward to your response!

Christopholus commented 1 year ago

Hi @bymayo - just wanted to check in on the above. I am unfortunately still running into this issue, now on Craft 4 (likely because both plugin versions are now using path to get the file.)

Any chance you had some time to look into a fix for this? We'd like to keep using this plugin with our non-public/gated files.

Thank you!