From 684fbad5bc7c8c923e8b5c3ce280a774e3bfc96e Mon Sep 17 00:00:00 2001 From: Kanwei Li Date: Tue, 4 Oct 2011 22:25:08 -0400 Subject: [PATCH] Force octet-stream MIME only when downloading datasets to prevent Safari from appending MIME extension --- lib/galaxy/web/controllers/dataset.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/web/controllers/dataset.py b/lib/galaxy/web/controllers/dataset.py index 6cb7598d369..32b6ed0de43 100644 --- a/lib/galaxy/web/controllers/dataset.py +++ b/lib/galaxy/web/controllers/dataset.py @@ -218,7 +218,7 @@ class DatasetInterface( BaseUIController, UsesAnnotations, UsesHistory, UsesHist outfname = data.name[0:150] outfname = ''.join(c in valid_chars and c or '_' for c in outfname) if (params.do_action == None): - params.do_action = 'zip' # default + params.do_action = 'zip' # default msg = util.restore_text( params.get( 'msg', '' ) ) messagetype = params.get( 'messagetype', 'done' ) if not data: @@ -370,6 +370,7 @@ class DatasetInterface( BaseUIController, UsesAnnotations, UsesHistory, UsesHist to_ext = data.extension valid_chars = '.,^_-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' fname = ''.join(c in valid_chars and c or '_' for c in data.name)[0:150] + trans.response.set_content_type( "application/octet-stream" ) #force octet-stream so Safari doesn't append mime extensions to filename trans.response.headers["Content-Disposition"] = "attachment; filename=Galaxy%s-[%s].%s" % (data.hid, fname, to_ext) return open( data.file_name ) if not os.path.exists( data.file_name ):