fileDownController.go 826 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * @Author: liling
  3. * @Date: 2022-08-13 14:38:13
  4. * @LastEditors: liling
  5. * @LastEditTime: 2022-08-13 14:38:15
  6. * @FilePath: \police_security\controllers\exelController.go
  7. * @Description:excel导入导出相关控制器
  8. *
  9. * Copyright (c) 2022 by liling/jujutong, All Rights Reserved.
  10. */
  11. package controllers
  12. type FileDownController struct {
  13. BaseController
  14. }
  15. func init() {
  16. }
  17. //公用文件下载方法
  18. //可通过该方法实现对目标文件进行下载权限、过虑、记录等操作
  19. func (this *FileDownController) Get() {
  20. //图片,text,pdf文件全部在浏览器中显示了,并没有完全的实现下载的功能
  21. //this.Redirect("/static/img/1.jpg", 302)
  22. //第一个参数是文件的地址,第二个参数是下载显示的文件的名称
  23. this.Ctx.Output.Download("static/img/1.jpg", "tu1.jpg")
  24. }