download URLs for FileField should end with filename not fieldname

Tim Hicks tim at sitefusion.co.uk
Mon Nov 12 15:44:42 UTC 2007


Tom Lazar wrote:
> thanks encolpe,
> 
> however, i don't fully understand:
> 
> On Nov 12, 2007, at 2:48 PM, Encolpe Degoute wrote:
> 
>> If you can suppose that you never have two times the same filename used
>> in a single document,
> 
> yes, that's the case
> 
>> you can iterate on schema and use
>> FileField.getFilename(self, instance, fromBaseUnit=True) to detect if
>> you're using the good field...
> 
> i already know how to retrieve the filename of the uploaded file, i want
> to know how it is possible to use it in a url so that the file is
> returned when somebody uses such an url.
> 
> i.e. instead of
> 
> http://nohost/plone/foo/filedata
> 
> i want to be able to use
> 
> http://nohost/plone/foo/bar.tgz
> 
> for download.

If you're happy with URLs like:

  http://nohost/plone/foo/filedata/bar.tgz

then you could probably use some kind of special traversal
(IPublishTraverse in Zope 2.10+, __bobo_traverse__ otherwise, I think).
 That would avoid you needing to make assumptions about no two file-ish
fields having a file with the same name.


Tim




More information about the Product-Developers mailing list