|
@@ -472,9 +472,11 @@ func ExcelImportWithImages(c *gin.Context, apictx *ApiSession, file io.Reader, g
|
|
|
}
|
|
|
|
|
|
// 设置响应头,使浏览器下载文件
|
|
|
- c.Header("Content-Description", "File Transfer")
|
|
|
- c.Header("Content-Disposition", "attachment; filename=import_result_"+time.Now().Format("20060102150405")+".xlsx")
|
|
|
- c.Data(http.StatusOK, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", buffer.Bytes())
|
|
|
+ fileName := "import_result_" + time.Now().Format("20060102150405") + ".xlsx"
|
|
|
+ c.Writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName))
|
|
|
+ c.Writer.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
|
+ c.Writer.Header().Set("Content-Transfer-Encoding", "binary")
|
|
|
+ c.Writer.Write(buffer.Bytes())
|
|
|
return nil, nil
|
|
|
|
|
|
// 统计导入结果
|
|
@@ -1143,9 +1145,10 @@ func ZipExport(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
}
|
|
|
|
|
|
// 设置响应头,使浏览器下载文件
|
|
|
- c.Header("Content-Description", "File Transfer")
|
|
|
- c.Header("Content-Disposition", "attachment; filename=export_"+time.Now().Format("20060102150405")+".zip")
|
|
|
- c.Data(http.StatusOK, "application/zip", zipData)
|
|
|
+ c.Writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=export_%s.zip", time.Now().Format("20060102150405")))
|
|
|
+ c.Writer.Header().Set("Content-Type", "application/zip")
|
|
|
+ c.Writer.Header().Set("Content-Transfer-Encoding", "binary")
|
|
|
+ c.Writer.Write(zipData)
|
|
|
|
|
|
return nil, nil
|
|
|
}
|