|
@@ -3,6 +3,7 @@ package com.macro.mall.tiny.modules.business.controller;
|
|
|
import com.macro.mall.tiny.common.api.CommonResult;
|
|
|
import com.macro.mall.tiny.domain.AdminUserDetails;
|
|
|
import com.macro.mall.tiny.modules.business.dto.FileUploadParam;
|
|
|
+import com.macro.mall.tiny.modules.business.model.BDirectory;
|
|
|
import com.macro.mall.tiny.modules.business.service.FileService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -62,47 +63,6 @@ public class FileController {
|
|
|
return CommonResult.success("上传成功,后台正在处理...");
|
|
|
}
|
|
|
|
|
|
- /*@ApiOperation("文件下载接口")
|
|
|
- @GetMapping("/download")
|
|
|
- public Object downloadFile(@RequestParam String fileName, final HttpServletResponse response) {
|
|
|
- OutputStream os = null;
|
|
|
- InputStream is = null;
|
|
|
- try {
|
|
|
- // 取得输出流
|
|
|
- os = response.getOutputStream();
|
|
|
- // 清空输出流
|
|
|
- response.reset();
|
|
|
- response.setContentType("application/x-download;charset=UTF-8");
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
|
|
- //读取流
|
|
|
- File f = new File(UploadConfig.path + fileName);
|
|
|
- is = new FileInputStream(f);
|
|
|
- //复制
|
|
|
- IOUtils.copy(is, response.getOutputStream());
|
|
|
- response.getOutputStream().flush();
|
|
|
- } catch (IOException e) {
|
|
|
- return CommonResult.failed("下载附件失败,error:" + e.getMessage());
|
|
|
- }
|
|
|
- //文件的关闭放在finally中
|
|
|
- finally {
|
|
|
- try {
|
|
|
- if (is != null) {
|
|
|
- is.close();
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- log.error("关闭文件输入流失败:", e);
|
|
|
- }
|
|
|
- try {
|
|
|
- if (os != null) {
|
|
|
- os.close();
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- log.error("关闭文件输出流失败:", e);
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }*/
|
|
|
-
|
|
|
/**
|
|
|
* 下载模板
|
|
|
*/
|
|
@@ -120,4 +80,10 @@ public class FileController {
|
|
|
outputStream.flush();
|
|
|
outputStream.close();
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation("文件上传接口")
|
|
|
+ @PostMapping("/upload")
|
|
|
+ public CommonResult<BDirectory> getDirectory(){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|