| | |
| | | |
| | | @Scheduled(cron = "0 0/1 * * * ?") |
| | | public void get() throws IOException { |
| | | log.error("同步上传"); |
| | | List<String> list = FtpApche.downloadList(ftpConfig); |
| | | |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | log.error("no files in ftp"); |
| | | log.error("同步互联网文件"); |
| | | List<String> list = FtpApche.downloadList(this.ftpConfig); |
| | | if (list.size() == 0) |
| | | return; |
| | | } |
| | | log.info("ftp get all fileinfo:" + list.get(0)); |
| | | for (String str : list) { |
| | | String password = str.substring(0, 6); |
| | | String fileName = str.substring(6, str.length()); |
| | | InputStream input = FtpApche.downloadFileFromDailyDir(str); |
| | | if (Objects.nonNull(input)) { |
| | | byte[] fileBytesByName = FtpApche.getFileBytesByName(input); |
| | | OssClient storage = OssFactory.instance(); |
| | | MockMultipartFile mockMultipartFile = new MockMultipartFile(fileName, fileName, fileName.substring(14, fileName.length()), input); |
| | | UploadResult uploadResult = storage.uploadSuffix2(fileBytesByName, getPath(fileName), "multipart/form-data; charset=ISO-8859-1"); |
| | | buildResultEntity(fileName, fileName.substring(14, fileName.length()), "minio", uploadResult, (MultipartFile)mockMultipartFile, password, fileBytesByName); |
| | | FtpApche.deleteFile(str); |
| | | } |
| | | byte[] fileBytesByName = FtpApche.getFileBytesByName(input); |
| | | OssClient storage = OssFactory.instance(); |
| | | MockMultipartFile mockMultipartFile = new MockMultipartFile(fileName, fileName, fileName.substring(14, fileName.length()), input); |
| | | UploadResult uploadResult = storage.uploadSuffix2(fileBytesByName, getPath(fileName), "multipart/form-data; charset=ISO-8859-1"); |
| | | FtpApche.deleteFile(str); |
| | | buildResultEntity(fileName, fileName.substring(14, fileName.length()), "minio", uploadResult, (MultipartFile)mockMultipartFile, password, fileBytesByName); |
| | | } |
| | | |
| | | } |
| | | |
| | | @NotNull |