Private downloads currently don't work perfectly, because as long as $_SESSION['imagefield'] contains the concerned file, it will be downloaded with _imagefield_preview() instead of file_download(). Which doesn't work.

This patch fixes that problem by clearing up session (imagefield_clear_field_session() on the respective field) when an imagefield is newly stored (either inserted or updated), so when the node is viewed there is no session variable for that field left. Which makes it work.

Please review and apply (the patch is for the DRUPAL-5--2 branch).

CommentFileSizeAuthor
imagefield_private_downloads.patch822 bytesjpetso

Comments

quicksketch’s picture

Status: Needs review » Closed (duplicate)

Thanks jpetso! I've wrapped your patch into part of http://drupal.org/node/123977, as it helps with that issue also. This should be committed shortly. Thanks!

quicksketch’s picture

Status: Closed (duplicate) » Reviewed & tested by the community

Sorry, that other issue seems to be caused by something else... I'll apply this as it's own commit.

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

Committed to all branches. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)
mschiff’s picture

Status: Closed (fixed) » Active

Hi,,

I am having this issue with drupal 6.15 and imagefield 6.x-3.2 (Link Image Field 6.x-1.x-dev is also affected)

I am using an imagefield and private downloads the the image URL starts with /system/files/. As authenticated user it works, but as anon user this will give a "file not found" error
(Note: not a permission denied error! Browser shows the broken image icon)

If I switch to public downloads all works well.

mschiff’s picture

Status: Active » Closed (fixed)

sorry for the noise, permissions error, only the "Link Image Field 6.x-1.x-dev" Module is affected