Edgewall Software
Modify

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:

  1. client request: http://server/trac/plugin/get_file?parameters
  2. trac emits a file
  3. 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)

8341.patch (922 bytes ) - added by Emmanuel Blot 15 years ago.
Simple patch to send file name
8341-send-file-r8246.patch (1.1 KB ) - added by Remy Blank 15 years ago.
Aribtrary file name (untested)

Download all attachments as: .zip

Change History (6)

by Emmanuel Blot, 15 years ago

Attachment: 8341.patch added

Simple patch to send file name

comment:1 by Remy Blank, 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.

by Remy Blank, 15 years ago

Attachment: 8341-send-file-r8246.patch added

Aribtrary file name (untested)

in reply to:  1 comment:2 by Remy Blank, 15 years ago

Replying to rblank:

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.

Done in [8260].

comment:3 by Remy Blank, 14 years ago

Milestone: next-major-0.1X0.13
Owner: set to Remy Blank

comment:4 by Remy Blank, 14 years ago

Milestone: 0.13
Resolution: wontfix
Status: newclosed

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.