Thursday 01 July 2010 2:36:38 pm
I'm trying to construct a link to a binary file (a PDF) that's in content class File. When I use the standard method of constructing the link via "content/download" the browser prompts me to download the file. However, I need the PDF to open in the browser window - this is the behavior I see if I link to a PDF file directly. I tried to link directly to the file using this method:
href={concat('/', $attribute.content.filepath)|ezroot()} But I get a 404 on the resulting link (which looks like /var/sitename/original/application/etc.) In addition, most of the files in my var folder don't have file extensions, so I'm not sure that the browser would even know what to do if I linked directly to one of the files (Firefox in particular tends not to recognize PDFs properly without their extension, at least I've seen that behavior before). Is there a recommended method to link directly to a binary file without using content/download to force the browser to download the file? Thanks! UPDATE: I tried setting the PassThroughSettings in file.ini, but it didn't seem to have any effect - the PDF still downloads instead of opening in the browser when I use the content/download link. [PassThroughSettings]
ContentDisposition[application/pdf]=inline
ContentDisposition[application/x-pdf]=inline
I resolved the 404 when linking directly to the file in var/ by changing my RewriteRules, but since the vast majority of files in that folder are missing their file extensions, the browser doesn't understand how to open the file without ".pdf" at the end. Any idea how I can restore those missing extensions? UPDATE 2: Apparently setting the ContentDisposition settings was sufficient, but for some reason the change didn't take until I cleared the cache through the admin, as opposed to command-line (not sure why). If you're curious about the missing extensions in the filenames, it's a known issue which was supposedly resolved in 4.0, but I think it is still out there, I just haven't nailed down the exact circumstances to reproduce. I was able to solve it by running this script, which got me most of the way there, and then running the following SQL statement (the script changed the file names correctly but did not update every record in the ezbinaryfile table): UPDATE ezbinaryfile SET filename=concat(filename, '.', SUBSTR(original_filename, -3)) WHERE (filename NOT LIKE '%.___') AND (original_filename LIKE '%.___');
That SQL copies the extension from the original filename into the new filename field (only if the original filename had an extension of a . and then 3 characters and the new filename does not already have that).
Me: http://jordan.teamhirsch.com
My blog: http://wiredformusic.blogspot.com
My other company: http://thinkimprov.com
eZ Certification: http://auth.ez.no/certification/verify/402488
eZ Award: http://ez.no/company/news/ez_awards_2007_prize_winners
|