直接调用FastDFS返回的url,浏览器访问后默认打开方式。
/usr/bin/fdfs_test /etc/fdfs/client.conf upload test.jpg
文件下载方案
1.调用download接口,定义下载的文件名
public void download(String fileUrl, HttpServletResponse response) throws Exception{
byte[] data = fdfsClient.download(fileUrl);
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("test.7z", "UTF-8"));
// 写出
ServletOutputStream outputStream = response.getOutputStream();
IOUtils.write(data, outputStream);
}
2.nginx反向代理增加请求头Content-disposition及attachment
server {
listen 8082;
server_name 192.168.8.200;
location /group1/M00 {
add_header Content-Disposition "attachment;filename=$arg_attname";
ngx_fastdfs_module;
}
}
在upload接口中进行url拼接
fdfsClient.uploadFile(file) + "?attname=" + file.getOriginalFilename()
FastDFS上传返回的url直接下载和下载文件的文件名问题
原文:https://www.cnblogs.com/jxd283465/p/11506568.html