返回文件下载流,当文件小于等于1k的时候,是正常响应的。
当大于1k的文件时,无报错,但是没有下载文件的响应。
返回代码为:
c.Header("Content-Type", "application/octet-stream")
c.Header("Content-Disposition", `attachment; filename=` + fileName)
c.Header("Content-Transfer-Encoding", "binary")
c.Data(200,"application/octet-stream",r)
无报错,响应头为:
access-control-allow-credentials: true
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
access-control-allow-methods: POST, GET, OPTIONS, PUT, DELETE, UPDATE
access-control-allow-origin: *
access-control-expose-headers: Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Cache-Control, Content-Language, Content-Type
content-disposition: attachment; filename=
content-type: application/octet-stream
date: Mon, 19 Oct 2020 01:43:39 GMT
transfer-encoding: chunked
有疑问加站长微信联系(非本文作者)