Java中实现⽂件下载通⽤⽅式⽂件下载只需要四步:
1.设置⽂件ContentType类型
response.setContentType("multipart/form-data");
2.设置⽂件头
plc编程教程迅雷下载电子书response.setHeader("Content-Disposition", "attachment;filename=" + de(fileName, "UTF-8"));
3.通过response获取ServletOutputStream对象(out)
InputStream inputStream = xxxxx.downloadFile(fileName);
4.写到输出流(out)中
inputStream.close();
下⾯给出代码块,亲测可执⾏:
1.基于OSS实现⽂件下载
@RequestMapping(value = "/ossDown",method = RequestMethod.GET)
@ResponseBody
源码网站叫什么@SneakyThrows
public void ossDown(@RequestParam("bucketName") String
bucketName,@RequestParam("fileName") String fileName, HttpServletResponse response){
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;filename=" +de(fileName, "UTF-8"));        InputStream inputStream = ossComponent.downloadFile(bucketName, fileName);
inputStream.close();
}
OSS执⾏组件部分,亲测可⾏,获取
2.基于minIO实现⽂件下载
/**
* 下载⽂件
* @param fileName
* @param response
* @throws Exceptionjava下载过程
举起手来
*/
@RequestMapping(value = "/minioDown",method = RequestMethod.GET)
@ResponseBody
url下载软件@SneakyThrows(Exception.class)
public void minioDown(@RequestParam("fileName") String fileName, HttpServletResponse response)throws Exception {
ObjectStat stat = minioUtils.statObject("peach", fileName);
response.tType());
response.setHeader("Content-Disposition", "attachment;filename=" + de(fileName, "UTF-8"));
InputStream in = Object("", fileName);
in.close();
}
关于minio的Java操作部分,,亲测可⾏,可直接项⽬使⽤,也可学习
>c语言switch语句题目

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。