When an attached file is listed in a post (or a Views table view lists files attached to posts) the path to the private file looks like example.com/files/private/etc and Apache returns a 403 error. When editing a node with a private attachment, the full URL is shown example.com/system/files/private/etc and works as expected.

This was tested with beta2 on Drupal 5.2 and 5.3.

Comments

starbow’s picture

Status: Active » Postponed (maintainer needs more info)

When an attached file is listed in a post

Can you tell me how you are listing the file in the post?

As for views, that is a good point. I will need to provide a custom view handler.

Christefano-oldaccount’s picture

Thanks for the response. The upload module lists the node's attachments in an "Attachments" table (I think it has an "attachments" id in the page source, too). These attachments are uploaded the normal way from the "File attachments" field in a node edit/create form. Clicking a private attachment should download it but the path is missing the system/ part of the URL.

Having private and public functionality in Drupal is critical. I'm very grateful that you're working on the problem.

starbow’s picture

Hmm, well the module should be rewriting the links in the attachment table. And on my test system it works.
Can you go into the code of the module, and edit line 549 in theme_private_upload_attachments from

  $href = _private_upload_create_url($file); // this is the changed line

to

  drupal_set_message( "filepath: $file->filepath" );
  $href = _private_upload_create_url($file); // this is the changed line
  drupal_set_message( "href: $file->filepath" );

and then post what shows up in your message box?

Christefano-oldaccount’s picture

    * private_upload_nodeapi: insert/update
    * The Event has been updated.
    * filepath: files/private/test.pdf
    * href: files/private/test.pdf

There are a few things going screwy and I'm wondering how to step back and effectively help troubleshoot this issue. I'll post again after I take a look at what other modules are installed.

Christefano-oldaccount’s picture

OK, you'd never guess it was the Upload Image module. Disabling Upload Image fixes the reported issue.

With Upload Image enabled, the Private Upload paths get screwed up when making an upload private (by checking the "private" checkbox in the "File attachments" fieldset). The funny thing is that in this test the attachment being uploaded isn't even an image.

edit: I'm opening a few new issues to report other conflicts I observed.

Christefano-oldaccount’s picture

Title: File paths to private files are incorrect » File paths to private files are incorrect when Upload Image is enabled
starbow’s picture

Title: File paths to private files are incorrect when Upload Image is enabled » Fix conflict with Upload Image
Category: bug » feature
Status: Postponed (maintainer needs more info) » Active

I will add this to the list of known issues.

starbow’s picture

Status: Active » Postponed (maintainer needs more info)

Hmm, actually I cannot find an Upload Image module. Can you let me know the URL?

Christefano-oldaccount’s picture

starbow’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)
starbow’s picture

I don't think there is anyway to get this module to play nicely with other modules that re-theme the file attachments.

Christefano-oldaccount’s picture

Thanks for looking into it. Private Upload is staggeringly useful and I wish I'd started using it in a particular project before committing to Upload Image.