从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())
上一篇:【MinIO】【CentOS】设置成服务开机启动


下一篇:牛笔了!docker安装minio