|
|
@@ -8,6 +8,7 @@ import com.coffee.common.result.R;
|
|
|
import com.coffee.common.result.ResultCode;
|
|
|
import com.coffee.oss.strategy.FileStorageStrategy;
|
|
|
import com.coffee.oss.strategy.context.FileStorageContext;
|
|
|
+import com.coffee.oss.strategy.storage.SysStorage;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.MediaType;
|
|
|
@@ -70,19 +71,19 @@ public class CommonController {
|
|
|
|
|
|
@PostMapping("/upload")
|
|
|
@SneakyThrows
|
|
|
- public R upload(MultipartFile file, HttpServletRequest request) {
|
|
|
- String bizPath = request.getParameter("bizPath");
|
|
|
+ public R<SysStorage> upload(@RequestParam("file") MultipartFile file, @RequestParam("file") String bizPath) {
|
|
|
if (StrUtil.isBlank(bizPath)) {
|
|
|
- throw new CustomException(ResultCode.PARAM_MISS.getMessage());
|
|
|
+ throw new CustomException(ResultCode.PARAM_TYPE_ERROR.getMessage());
|
|
|
}
|
|
|
if (Objects.isNull(file)) {
|
|
|
- throw new CustomException(ResultCode.PARAM_MISS.getMessage());
|
|
|
+ throw new CustomException(ResultCode.PARAM_TYPE_ERROR.getMessage());
|
|
|
}
|
|
|
FileStorageStrategy fileStorageStrategy = fileStorageContext.getContext();
|
|
|
- String url = fileStorageStrategy.upload(file, bizPath);
|
|
|
- return R.success(url);
|
|
|
+ SysStorage storage = fileStorageStrategy.upload(file, bizPath);
|
|
|
+ return R.success(storage);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@GetMapping("/download")
|
|
|
@SneakyThrows
|
|
|
public void download(@RequestParam String filepath, HttpServletResponse response) {
|