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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

Status: Active » Closed (duplicate)
webchick’s picture

Title: Page not found error with private files » hook_file_download() causes 404 for filefield-derived fields on private download
Category: support » bug
Priority: Normal » Critical
Status: Closed (duplicate) » Needs work

I'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.

webchick’s picture

dopry’s picture

Status: Needs work » Fixed

thats a perfectly fine solution until the image field type is gone... It is deprecated. committed to HEAD

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.