|
|
|
@ -37,8 +37,7 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.*; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -144,6 +143,38 @@ public class DgApplyAmountInfoController implements DgApplyAmountInfoControllerA |
|
|
|
|
return ResponseResult.SUCCESS(list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 下载单个文件 |
|
|
|
|
* |
|
|
|
|
* @param response |
|
|
|
|
* @param fileName |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@RequestMapping("/download") |
|
|
|
|
public String download(HttpServletResponse response, @RequestParam("fileName") String fileName) { |
|
|
|
|
File file = new File(PromptSuccess.FILE_URL_PATH + fileName); |
|
|
|
|
if (file.exists()) { |
|
|
|
|
response.setContentType("application/force-download;charset=UTF-8"); |
|
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName =" + fileName); |
|
|
|
|
byte[] buffer = new byte[1024]; |
|
|
|
|
|
|
|
|
|
try (FileInputStream inputStream = new FileInputStream(file); |
|
|
|
|
OutputStream outStream = response.getOutputStream(); |
|
|
|
|
BufferedInputStream buffStream = new BufferedInputStream(inputStream);) { |
|
|
|
|
int i = 0; |
|
|
|
|
while ((i = buffStream.read(buffer)) != -1) { |
|
|
|
|
outStream.write(buffer); |
|
|
|
|
outStream.write(buffer, 0, i); |
|
|
|
|
} |
|
|
|
|
return "download success"; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("download error {}", e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 删除服务上的文件 |
|
|
|
|
* @param filePath 路径 |
|
|
|
|