Share » Forums » General » Removing/Disabling Id data from...

Removing/Disabling Id data from URLs/paths contents

Removing/Disabling Id data from URLs/paths contents

Tuesday 31 August 2010 9:05:07 pm - 6 replies

Modified on Wednesday 01 September 2010 4:27:25 pm by Russell Michell

Author Message

Jérôme Vieilledent

Wednesday 01 September 2010 11:45:28 pm

Hi Russ

I guess that you made some kind of attribute_view_gui to get this link. This is IMHO the best way to give a file for download. Another approach would be to display the physical link in your template :

<a href={$node.data_map.file.content.filepath|ezroot} target="_blank">{$node.data_map.file.original_filename|wash}</a>

Jérôme Vieilledent

Wednesday 01 September 2010 11:47:45 pm

(...) and as a default perhaps just overwrite a file when it gets updated?

I have no need for versioning of these kinds of files.

I don't get it... What do you need exactly ? Are you talking about import ?

Russell Michell

Monday 13 September 2010 1:34:41 pm

(...) and as a default perhaps just overwrite a file when it gets updated?

I have no need for versioning of these kinds of files.

I don't get it... What do you need exactly ? Are you talking about import ?

Hi there,

No I'm not talking about import. I have overridden embed.tpl so I can directly download files instead of having to click twice to download it. However the URI of the link appears like this:

/content/download/12345/78964/file/blah.pdf

I wanted to remove the 12345/78964 part. I managed it using ReWrites but it got too complex to manage!

It's not too important now I can live with it. However, I don't think downloading a file should really make any underlying systems viewable to the user. Would it not be desirabl and more flexible in tems of template overrides if it were transparent? The URI would look like /content/download/file/blah.pdf but eZ simply fetched the latest version of blah.pdf - better, the URL would take the form of the file-structure in Media/Files so you could have multiple files named "blah.pdf".

Thanks anyway, I have got what I needed for now :-)

Cheers
Russ

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Marko Žmak

Thursday 16 September 2010 11:27:40 am

Russell, the thing that you are trying to achieve seems pretty much theoretically impossible...

Let's say for example that you have a content class "Double file" which has two attributes of type "File". And let's say that you create an object of this class and upload a file in each of this two attributes both files named blah.pdf.

So now what would be the URL for downloading each of this files? How would you know the difference between them without putting the attribute id (or identifier) in the URL?

As for your remark:

However, I don't think downloading a file should really make any underlying systems viewable to the user.

look at all those download sites on the net, they all have some kind of ID in the URL that reveals some part of the underlying system. So it's perfectly reasonable.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Gaetano Giunta

Friday 17 September 2010 4:19:42 am

If you only have a single attribute with the binary file in your content class, you might:

1) simple solution: use an http redirect

2) create a new fetch function and serve the binary content via template (hackish!)

3) create an alternative module to content/download

for 1: override full.tpl for your class, in it just set a redirect_location in the persistent_variable that points to the correct :content/download/xxx link, and in the pagelayout check if redirect_location is set, and if it is, do an http redirect to it (needs a new tpl operator for it)

for 2: override full.tpl for your class, in it set a file_location and mime_type in the persistent_variable; the again add code in the pagelayout that when those variables are found juset does a readfile() of the binary content and sends appropriate mime headers

for 3: I'll leave it up to you to code the new module+view that looks up node id by path and then gets the binary file and pipes it to the user. Urls might look like /my/download/path/to/the/node - here again you should add rewrite rules / redirects to get to a "clean" solution

Principal Consultant International Business
Member of the Community Project Board

Marko Žmak

Friday 17 September 2010 7:24:28 am

The solution that I use for classes that have only one file attribute is to do a HTTP redirect to the /content/download/12345/78964/file/blah.pdf URL in the full view of the file class.

You can do the redirection using RedirectOperators contribution.

Of course, in security context, this doesn't hide completely the IDs from the user but it does hide the "ugly" url from the user.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

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

36 542 Users on board!

Forums menu