b45f0b9b by astaxie

beego: fix #478

1 parent cf04ade6
...@@ -237,10 +237,14 @@ func (output *BeegoOutput) Xml(data interface{}, hasIndent bool) error { ...@@ -237,10 +237,14 @@ func (output *BeegoOutput) Xml(data interface{}, hasIndent bool) error {
237 237
238 // Download forces response for download file. 238 // Download forces response for download file.
239 // it prepares the download response header automatically. 239 // it prepares the download response header automatically.
240 func (output *BeegoOutput) Download(file string) { 240 func (output *BeegoOutput) Download(file string, filename ...string) {
241 output.Header("Content-Description", "File Transfer") 241 output.Header("Content-Description", "File Transfer")
242 output.Header("Content-Type", "application/octet-stream") 242 output.Header("Content-Type", "application/octet-stream")
243 output.Header("Content-Disposition", "attachment; filename="+filepath.Base(file)) 243 if len(filename) > 0 && filename[0] != "" {
244 output.Header("Content-Disposition", "attachment; filename="+filename[0])
245 } else {
246 output.Header("Content-Disposition", "attachment; filename="+filepath.Base(file))
247 }
244 output.Header("Content-Transfer-Encoding", "binary") 248 output.Header("Content-Transfer-Encoding", "binary")
245 output.Header("Expires", "0") 249 output.Header("Expires", "0")
246 output.Header("Cache-Control", "must-revalidate") 250 output.Header("Cache-Control", "must-revalidate")
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!