| | |
| | | |
| | | @PostMapping("/upload.action") |
| | | public R upload(MultipartFile file) { |
| | | String suffix = file.getName().substring(file.getName().lastIndexOf(".") + 1); |
| | | InputStream inputStream = null; |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String upload=ossService.upload(inputStream,suffix); |
| | | String upload = ossService.upload(inputStream,file.getOriginalFilename()); |
| | | return R.ok(Cools.add("url", upload)); |
| | | } |
| | | |
| | |
| | | return R.error("图片上传数量已到上限"); |
| | | } |
| | | // oss |
| | | String suffix = file.getName().substring(file.getName().lastIndexOf(".") + 1); |
| | | InputStream inputStream = null; |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String upload = ossService.upload(inputStream,suffix); |
| | | String upload = ossService.upload(inputStream,file.getOriginalFilename()); |
| | | if (Cools.isEmpty(upload)) { |
| | | return R.error("上传OSS服务失败"); |
| | | } |