download URLs for FileField should end with filename not fieldname

Encolpe Degoute encolpe.degoute at ingeniweb.com
Mon Nov 12 13:48:46 UTC 2007


Tom Lazar a écrit :
> has anybody got an idea how to have a download url for a FileField
> attribute that includes the name of the uploaded file?
> 
> currently, if an AT's FileField is named e.g. 'filedata' then all the
> download links for that AT content type's file end in /filedata which is
> confusing, when people download the file.
> 
> question: is there a sane way to create download url that ends with the
> file's filename?

If you can suppose that you never have two times the same filename used
in a single document, you can iterate on schema and use
FileField.getFilename(self, instance, fromBaseUnit=True) to detect if
you're using the good field...
There's other issues:
- you must do this in a tool or in an utility as many methods you will
  use are private
- iterations will slow down your site
- filename must be unique in a content type


-- 
Encolpe Degoute
INGENIWEB (TM) - S.A.S 50000 Euros - RC B 438 725 632
17 rue Louise Michel - 92300 Levallois Perret - France
web : www.ingeniweb.com - « les Services Web Ingénieux »
Tel : 01.78.15.24.08 / Fax : 01 47 57 39 14





More information about the Product-Developers mailing list