从MINIO获取文件然后返回前台文件流
作者:互联网
minioObject, getObjErr := minioClient.GetObject(ConfigUtil.MinioBucket, key, minio.GetObjectOptions{})
if getObjErr != nil {
c.JSON(http.StatusOK, gin.H{"success": false, "info": "获取文件信息异常!" + getObjErr.Error()})
return
}
buf := bytes.NewBuffer(nil)
io.Copy(buf, minioObject)
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", originName))
c.Data(http.StatusOK, "application/octet-stream", buf.Bytes())
标签:getObjErr,http,MINIO,minioObject,文件,nil,StatusOK,前台,buf 来源: https://www.cnblogs.com/kgdxpr/p/14977952.html