beego: fix #478
Showing
1 changed file
with
5 additions
and
1 deletions
| ... | @@ -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 | if len(filename) > 0 && filename[0] != "" { | ||
| 244 | output.Header("Content-Disposition", "attachment; filename="+filename[0]) | ||
| 245 | } else { | ||
| 243 | output.Header("Content-Disposition", "attachment; filename="+filepath.Base(file)) | 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") | ... | ... |
-
Please register or sign in to post a comment