文件删除接口
Showing
1 changed file
with
14 additions
and
5 deletions
| ... | @@ -4,10 +4,7 @@ import com.pashanhoo.common.Result; | ... | @@ -4,10 +4,7 @@ import com.pashanhoo.common.Result; |
| 4 | import io.swagger.annotations.Api; | 4 | import io.swagger.annotations.Api; |
| 5 | import io.swagger.annotations.ApiOperation; | 5 | import io.swagger.annotations.ApiOperation; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | import org.springframework.web.bind.annotation.RequestMapping; | 7 | import org.springframework.web.bind.annotation.*; |
| 8 | import org.springframework.web.bind.annotation.RequestMethod; | ||
| 9 | import org.springframework.web.bind.annotation.RequestPart; | ||
| 10 | import org.springframework.web.bind.annotation.RestController; | ||
| 11 | import org.springframework.web.multipart.MultipartFile; | 8 | import org.springframework.web.multipart.MultipartFile; |
| 12 | 9 | ||
| 13 | import javax.servlet.http.HttpServletResponse; | 10 | import javax.servlet.http.HttpServletResponse; |
| ... | @@ -24,7 +21,8 @@ public class FileController { | ... | @@ -24,7 +21,8 @@ public class FileController { |
| 24 | 21 | ||
| 25 | @Autowired | 22 | @Autowired |
| 26 | MinioUtil minioUtil; | 23 | MinioUtil minioUtil; |
| 27 | 24 | @Autowired | |
| 25 | MinioConfig minioConfig; | ||
| 28 | 26 | ||
| 29 | @RequestMapping(value = "/upload", method = RequestMethod.POST) | 27 | @RequestMapping(value = "/upload", method = RequestMethod.POST) |
| 30 | @ApiOperation("上传单个文件") | 28 | @ApiOperation("上传单个文件") |
| ... | @@ -48,4 +46,15 @@ public class FileController { | ... | @@ -48,4 +46,15 @@ public class FileController { |
| 48 | } | 46 | } |
| 49 | } | 47 | } |
| 50 | 48 | ||
| 49 | @DeleteMapping("/deleteFile") | ||
| 50 | @ApiOperation("删除文件") | ||
| 51 | public Result deleteFile(@RequestParam("saveUrl") String saveUrl){ | ||
| 52 | try { | ||
| 53 | minioUtil.removeObject(minioConfig.getBucket(), saveUrl); | ||
| 54 | return Result.ok(); | ||
| 55 | } catch (Exception e) { | ||
| 56 | return Result.exception(e.getMessage()); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 51 | } | 60 | } | ... | ... |
-
Please register or sign in to post a comment