Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
While testing attachment_links on a project using a private:// file-field, I got 404 errors. I discovered two things:
- File paths from the file stream wrapper are URL encoded, but
file_download()
needs a real file name or it returns a 404. (My issue: filenames with spaces.) - When using
file_download()
instead ofdrupal_goto()
, the filename gets lost.
Here's a patch I wrote to address both issues.
Comment | File | Size | Author |
---|---|---|---|
#1 | 2030701-1.patch | 1.14 KB | ultimateboy |
attachment_links.private_links_fixes.patch | 1.31 KB | tsmith512 |
Comments
Comment #1
ultimateboy CreditAttribution: ultimateboy commentedGreat patch which solves my issues with private files and the attachment_links module.
I've fixed the root of the patch (you had originally patched from your drupal root and not the module's root).
No real changes to the patch and thus I'm marking RTBC.
Comment #2
ultimateboy CreditAttribution: ultimateboy commentedI should note that before adding this patch, links to node/#/attachment/newest were downloading with a filename of "newest" instead of the desired filename. The fact that this patch adds the
header()
information also fixes this issue.Comment #3
ruplAwesome, thanks for the confirmation and re-roll. Committed to dev: ce0d5506