| | |
| | | @PostMapping("put-file-app") |
| | | public R putFileApp(@RequestParam MultipartFile file) throws IOException, ServerException, InsufficientDataException, InternalException, InvalidResponseException, InvalidKeyException, NoSuchAlgorithmException, XmlParserException, ErrorResponseException { |
| | | //填写你文件上传的地址以及相应信息 |
| | | String url = "http://192.168.0.109:9000"; |
| | | String access = "minioadmin"; |
| | | String secret = "minioadmin"; |
| | | String url = "http://223.82.109.183:2081"; |
| | | String access = "zhbaadmin"; |
| | | String secret = "zhbapassword"; |
| | | String bucket = "zhba"; |
| | | MinioClient minioClient = |
| | | MinioClient.builder() |
| | |
| | | .headers(headers) |
| | | .build()); |
| | | in.close(); |
| | | String urls = "http://192.168.0.109:9000/zhba/" + newName; |
| | | String urls = "http://223.82.109.183:2081/zhba/" + newName; |
| | | return R.data(urls); |
| | | } |
| | | |
| | |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-attach") |
| | | public R<BladeFile> putFileAttach(@RequestParam MultipartFile file,String deptid,String type,Long noticeId) { |
| | | public R<BladeFile> putFileAttach(@RequestParam MultipartFile file,String deptid,String type,Long noticeId,String cardid) { |
| | | String fileName = file.getOriginalFilename(); |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type,noticeId); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type,noticeId,cardid); |
| | | bladeFile.setAttachId(attachId); |
| | | return R.data(bladeFile); |
| | | } |
| | |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-attach-by-name") |
| | | public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file,String deptid,String type,Long noticeId) { |
| | | public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file,String deptid,String type,Long noticeId,String cardid) { |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type,noticeId); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type,noticeId,cardid); |
| | | bladeFile.setAttachId(attachId); |
| | | return R.data(bladeFile); |
| | | } |
| | |
| | | * @param bladeFile 对象存储文件 |
| | | * @return attachId |
| | | */ |
| | | private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type,Long noticeId) throws Exception { |
| | | private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type,Long noticeId,String cardid) throws Exception { |
| | | //BladeUser user = AuthUtil.getUser(); |
| | | String fileExtension = FileUtil.getFileExtension(fileName); |
| | | Attach attach = new Attach(); |
| | |
| | | attach.setAttachSize(fileSize); |
| | | attach.setExtension(fileExtension); |
| | | attach.setDeptid(deptid); |
| | | attach.setCardid(cardid); |
| | | attach.setType(type); |
| | | if (null!=noticeId){ |
| | | attach.setNoticeId(noticeId); |