When you try to access generated files stored in private filesystem you get a 403 access denied error.
Tested on a stock Drupal 7.21 + pdfpreview 2.1.
If you set the default filesystem to private, even files uploaded in pubblic fields don't work, because the module sends them to the default filesystem.

I'm not sure what should be done here, I think the generated file should be somehow registered with the file_managed table, because otherwise it's not possible to access a file object.

Comments

NicolasZanotti’s picture

I have the same issue. I can see that the file is generated correctly in the file system. However, access is denied when called via /system/files/...

NicolasZanotti’s picture

I was able to work around this issue by installing the Private files download permission module and then allowing authenticated users to access the preview folder.

molenick’s picture

+1.

A----’s picture

Issue summary: View changes

That's because you'd have to define a hook to allow access to your previews. Something along those lines :

function mymodule_file_download($uri) {
    $path = variable_get('pdfpreview_pathtoimages', 'pdfpreview');

    if (strpos($uri, $path) !== FALSE /* && any check that you'd like */) {
        $ret = array( 'Content-Type' => 'image/jpeg');
    }
    else {
        $ret = NULL;
    }

    return $ret;
}

It's also necessary for image styles as the original image access rights are check prior to thumbnail generation.

helmo’s picture

Status: Active » Closed (duplicate)
Related issues: +#2553845: Preview image should use same file system as that of its parent PDF

I think #2553845: Preview image should use same file system as that of its parent PDF has the patch for this ... marking as duplicate.

mschudders’s picture

I needed to hook #4 to fix this issue aswell.

Patch didn't solve my problem.

Use case:
Private file system
PDFpreview
File type => Manage display as PDF preview. (Not a Node)