Opened 15 years ago
Closed 14 years ago
#8341 closed enhancement (wontfix)
[PATCH] Add an option to send filenames
Reported by: | Emmanuel Blot | Owned by: | Remy Blank |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | attachment | Version: | none |
Severity: | minor | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Trac does not allow to send the name of a file being sent to the web client.
Although this option may not be useful with Trac core for now, this feature can be very useful for plugins that need to send files. The main use case for this feature is when the filename is generated: web client request for some data, and the plugin sends back a named file: without the proper content header, the browser gets the name from the URL, which may not match the actual filename.
Example:
- client request: http://server/trac/plugin/get_file?parameters…
- trac emits a file
- client stores the received file based on the original URL, here '
get_file
'
It would be nice to be able to send the actual file name to the client
See attached patch
Attachments (2)
Change History (6)
by , 15 years ago
Attachment: | 8341.patch added |
---|
follow-up: 2 comment:1 by , 15 years ago
Instead of using a boolean send_name
argument, I'd rather have an optional filename
argument that allows the file name to be chosen arbitrarily. Files are not necessarily stored with the same name as appearing to the user. The file name should be quoted, too, but that's what content_disposition()
is for (see the patch below).
OTOH, this would only be a convenience, as you can set the Content-Disposition
header prior to calling send_file()
(that's what the attachment module does).
OT: The filename
argument of content_disposition()
seems suspect to me, as it won't work if it is None
. I'll fix that shortly.
comment:2 by , 15 years ago
comment:3 by , 14 years ago
Milestone: | next-major-0.1X → 0.13 |
---|---|
Owner: | set to |
comment:4 by , 14 years ago
Milestone: | 0.13 |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
On second thought, I'd rather add a Content-Disposition
header "manually" before calling send_file()
, as this allows using either the inline
or the attachment
type.
Simple patch to send file name