Remove @@download from the file link so that the file can open up in the browser

Is there a way to remove @@download from the file content type so that the document can open up in the browser instead of being asked to download the file onto the computer? Both the Plone file content type and my Dexterity file content type are behaving in the same way.

Can it be changed:
FROM
https://www.somewhere.com/test-documents/01test.pdf/@@download/file/01test.pdf

TO
https://www.somewhere.com/test-documents/01test.pdf/

Any help or advice would be most appreciated. Thank you.

The @@download URL is generated here:

plone/formwidget/namedfile/widget.py:    def download_url(self):

and used here

plone/formwidget/namedfile/file_display.pt:           tal:attributes="href view/download_url">Filename</a>

Either customize the method generating the URL (monkeypatching) or customize the rendering template (z3c.jbot).

Or use Javascript for fixing the URLs clientside

No need for customization... just replace the @@download to @@display-file and you’re good to go.

1 Like

Which is of course a customization that must be made somewhere and somehow.

I guess you’re right :sweat_smile:

Hey everyone! Thanks so much! I replaced @@download with @@display-file in my Dexterity templates and it worked like a charm. You all rock! Thanks so much!!! Cheers. :grinning:

2 Likes

You might get some inspiration from this:
https://github.com/smcmahon/collective.download_fixes