This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » Developer » Cannot see file extension for my files
expandshrink

Cannot see file extension for my files

Cannot see file extension for my files

Wednesday 26 June 2013 2:19:33 pm - 5 replies

Hi there.

When I try to download a file (a pdf file for example) I cannon see the extension. The downloaded file looks like "abcdefgh" so I have to rename it into something.pdf

Is there a way to show  the real name, or at least, its extension?
I use the following sintax

 $object.data_map.file.content.filepath|ezroot}

Thank you! 

Modified on Wednesday 26 June 2013 7:31:42 pm by Simone Conti

Thursday 27 June 2013 11:25:20 am

Mmm, this gives the user direct access to the file - which bypasses all security checks of eZ.

You should go via content/download instead, as it is more secure and more flexible (eg works in cluster mode as well).

If you just want to link directly to the files on disk, then you should look up the html spec on how to suggest a proper file name for downloads, using content-disposition and friends

Thursday 27 June 2013 11:55:15 am

Quote from Gaetano Giunta :

Mmm, this gives the user direct access to the file - which bypasses all security checks of eZ.

You should go via content/download instead, as it is more secure and more flexible (eg works in cluster mode as well).

If you just want to link directly to the files on disk, then you should look up the html spec on how to suggest a proper file name for downloads, using content-disposition and friends

Could you be more specific? 

I just need to allow people to download my files shown on the page, nothing else! The only problem is that some files seems to have no extension when downloded.

I agree with you when you say that showing the full path is not so elegant (/var/<siteaccess>/storage/...) but I did not manage to hide it.

Thursday 27 June 2013 8:35:54 pm

try using "attribute_view_gui" in the tpl, where the attribute in question is of type "file". You will see that it generates links pointing to /content/download/xy/zw instead of /var/storage/etc.

This is waht I recommend you do as well

Friday 28 June 2013 12:09:51 pm

Quote from Gaetano Giunta :

try using "attribute_view_gui" in the tpl, where the attribute in question is of type "file". You will see that it generates links pointing to /content/download/xy/zw instead of /var/storage/etc.

This is waht I recommend you do as well

This is good for my related objects. In this case I can create a foreach() loop and call {attribute_view_gui} for each element.

 

But what about those files embedded directly in my page? 

Now I have an override like this:

<a href={$object.data_map.file.content.filepath|ezroot} class="pdf_link" target="_blank">{$object.data_map.name.content}</a>

I believe I can modify this to reflect your idea... but how?

thanks

 

[EDIT]

I just tried your solution but something is not working (my fault... for sure!).

{foreach $files as $F}

 {attribute_view_gui attribute=$F  view=file} 

{/foreach}

 

This code generate an error:

None of the templates design:content/datatype/view/.tpl, design:content/datatype/view/.tpl could be found

 

So I decided to create a file called file.tpl inside content/datatype/view.
But, what do I have to put inside /templates/content/datatype/view/file.tpl to make things work?

I tried with $object.something and $node.something but this two entities does not exists! 

Modified on Friday 28 June 2013 12:43:47 pm by Simone Conti

Friday 28 June 2013 3:05:12 pm

Thanks to Mr Gaetano Giunta I've found a solution.

I modified my overridden template for embeded files (design/SITEACCESS/override/templates/embed/myfile.tpl)

 <span style="font-size: 1.1em;">{def $U= concat( 'content/download/', $object.data_map.file.contentobject_id, '/', $object.data_map.file.id,'/version/', $object.data_map.file.version , '/file/', $object.data_map.file.content.original_filename|urlencode )}</span>
 
 
<a href={$U|ezurl} class="pdf_link" target="_blank">{$object.data_map.name.content}</a>
 
{undef $U}

and I used {content_view_gui content_object=$F view=embed} to display my linked files.

Now path is correct!

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from