| | |
| | | |
| | | @RequestMapping(value = "/plan/insert/file/auth") |
| | | // @ManagerAuth |
| | | public R insertFile(@RequestParam("planId") String planId,@RequestParam MultipartFile file){ |
| | | try{ |
| | | InputStream inputStream = file.getInputStream(); |
| | | // 获取文件的内容类型 |
| | | String contentType = file.getContentType(); |
| | | String suffix = getFileSuffix(file.getOriginalFilename()); |
| | | String url = ossService.upload(inputStream, suffix,contentType); |
| | | // String url = "http://tjdt.oss-cn-hangzhou.aliyuncs.com/"+file.getOriginalFilename(); |
| | | String[] names = url.split("com/"); |
| | | String name= names[1]; |
| | | public R insertFile(@RequestParam("planId") String planId, @RequestParam("filename") String filename, @RequestParam("filesize") Long filesize) { |
| | | try { |
| | | // InputStream inputStream = file.getInputStream(); |
| | | // // 获取文件的内容类型 |
| | | // String contentType = file.getContentType(); |
| | | // String url = ossService.upload(inputStream, file.getOriginalFilename(), contentType); |
| | | //// String url = "http://tjdt.oss-cn-hangzhou.aliyuncs.com/"+file.getOriginalFilename(); |
| | | // String[] names = url.split("com/"); |
| | | // String name= names[1]; |
| | | |
| | | |
| | | String[] split = planId.split("-"); |
| | | int id = Integer.parseInt(split[1]); |
| | | planService.increasePlanUrl(id,url,name,file.getSize()); |
| | | |
| | | /*String[] split = planId.split("-"); |
| | | int id = Integer.parseInt(split[1]); |
| | | System.out.println("---开始---"); |
| | | String savePath = "D:/crm/plan/file/"+id+"/"; // 指定保存文件的路径 |
| | | try{ |
| | | FileSaveExampleUtil.saveFile(file, savePath); |
| | | }catch (Exception e){ |
| | | return R.error(); |
| | | }*/ |
| | | String url = "http://zhongyang-ftpserver.oss-cn-hangzhou.aliyuncs.com/" + filename; |
| | | planService.increasePlanUrl(id, url, filename, filesize); |
| | | return R.ok(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | System.out.println(e); |
| | | return R.error(); |
| | | } |