Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I've enabled Private files in Drupal 6.3. When uploading files via my CCK filefield, the file uploads correctly and gets placed in the correct folder, but when I try to download it from the node view, I receive a page not found error. The core upload module works fine using the same folder to store the uploaded files.
I've tried changing view permissions on the CCK filefield and using folders both inside and outside the webroot but neither fixed the problem. If I use public files, everything works fine.
Comment | File | Size | Author |
---|---|---|---|
#3 | filefield-404-private-download-imagefield-291383-3.patch | 690 bytes | webchick |
Comments
Comment #1
amitaibuI think it's a duplicate of #290199: 403 Error while downloading uploaded file
Comment #2
webchickI'm not sure this is the same bug as the original poster, but it seems closest from what I found in my searching.
For more info see this ImageField bug: #301888: Image previews fail to display with private files directory outside of web root.
With modules such as ImageField which derive from FileField, they get a 404 on download when private file access is enabled. This is because the logic in filefield_file_download() does an explicit check for type == 'filefield' and in the case of an imagefield it's type == 'image'.
This patch fixes the problem, but I'm marking needs work because it'd be better to have a more future-proof way of figuring out whether a given field type should be governed by filefield_file_download().
It's also possible this is a bug in that imagefield should be implementing its own hook_file_download(), but there's an awful lot of logic in that function that would be nice to not have to copy/paste per filefield-derived field type.
Comment #3
webchickOops. Patch.
Comment #4
dopry CreditAttribution: dopry commentedthats a perfectly fine solution until the image field type is gone... It is deprecated. committed to HEAD