golnag获取流文件大小
使用fileObj.Stat()
fileObj,err := os.Open("./xxxx.go")
fileInfo,err := fileObj.Stat()
fmt.Printf("文件大小为: %dB\n",len(fileInfo))
golnag下载文件返回流文件大小 len(data)就是流文件大小
fileName := c.Query("fileName") //asc desc
fmt.Println(fileName)
data, _ := models.DownloadOssFile("beego", fileName)
// fmt.Println(data)
c.Header("Content-Type", "application/octet-stream")
c.Header("Content-Disposition", "attachment; filename="+fileName)
c.Header("Content-Transfer-Encoding", "binary")
c.Header("Content-Length", strconv.Itoa(len(data))) //非常重要 不然获取不到文件大小
c.Header("Cache-Control", "no-cache")
c.Writer.WriteHeader(http.StatusOK)
c.Writer.Write(data)