eZ Community » Forums » General » File attribute rename
expandshrink

File attribute rename

File attribute rename

Tuesday 24 September 2013 10:49:28 am - 5 replies

Hi to all,

I just need to keep file name during upload in "file" attribute.
Example, I upload "name_file.pdf" in a file attribute, in my website when I download the file the PDF has a unique name like 99864c22ab087582cdb0d4e911bed3e8.pdf stored in /var/ezwebin_site/storage/original/application/

I just want to keep original file name (not just label name!!).
I want that the downloaded file name remain.

Is it possible?

Thanks
Luca 

Tuesday 24 September 2013 2:32:45 pm

Hello Luca,

I use this following code to download pdf with the original filename :

 <a href={concat("content/download/",$object.main_node.data_map.file.contentobject_id,"/",$object.main_node.data_map.file.id,"/file/",$object.main_node.data_map.file.content.original_filename)|ezurl}>

file is the attribute identifier of my file attribute. 

Hope this helps.

Romain

 

Wednesday 25 September 2013 12:30:14 pm

Great Romain,

you made my day. Works like a charm!
Thank you!

Modified on Wednesday 25 September 2013 12:30:27 pm by Luca Mischiatti

Wednesday 02 October 2013 4:54:57 pm

Hi Guys,

Romain's solution work fine, but I can't view my pdf files on browser but just download them (with the old method works fine instead).

Is there a way to force browser to open files instead of download them?

Thanks

Luca

Wednesday 02 October 2013 5:24:33 pm

Hi Luca,

try this :

 <a target="_blank" href={concat("content/pdf/view/full/",
                        $object.main_node.data_map.file.contentobject_id,
                        "/",
                        $object.main_node.data_map.file.id,
                        "/file/",
                        $object.main_node.data_map.file.content.original_filename)|ezurl}>
                        {$object.name}</a>

Be careful with this solution. I'm not sure it's works on all browsers.

Romain

Wednesday 02 October 2013 5:29:41 pm

Hi Romain,

I found another way...but it's working just with file attribute and not with related object pdf file.

in file.ini under 

[PassThroughSettings]
ContentDisposition[application/pdf]=inline
ContentDisposition[application/x-pdf]=inline

I will test yours!

UPDATE

Your solution doesn't work...seems that EZ make a pdf on the fly with my object.

Modified on Wednesday 02 October 2013 5:33:18 pm by Luca Mischiatti

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from