| | |
| | | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.fasterxml.jackson.databind.SerializationFeature; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.DateUtils; |
| | | import org.dromara.common.oss.core.OssClient; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class VideoPulSync { |
| | | |
| | |
| | | this.baseMapper = baseMapper; |
| | | } |
| | | |
| | | // @Scheduled(cron = "0 0/1 * * * ?") |
| | | @Scheduled(cron = "0 0/1 * * * ?") |
| | | public void get() throws IOException { |
| | | System.out.println("同步上传......"); |
| | | |
| | | log.info("同步上传"); |
| | | List<String> list = FtpApche.downloadList(ftpConfig); |
| | | |
| | | if(list.size() == 0){ |
| | | log.error("no files in ftp"); |
| | | System.out.println("ftp get 0 fileinfo"); |
| | | return; |
| | | } |
| | | System.out.println("ftp get all fileinfo:" + list.get(0)); |
| | | for (String str : list) { |
| | | //密码 |
| | | String password = str.substring(0,6); |
| | | //文件名称 |
| | | String fileName = str.substring(6,str.length()); |
| | | String password = str.substring(0, 6); |
| | | String fileName = str.substring(6, str.length()); |
| | | InputStream input = FtpApche.downloadFileFromDailyDir(str); |
| | | byte[] fileBytesByName = FtpApche.getFileBytesByName(input); |
| | | OssClient storage = OssFactory.instance(); |
| | | MultipartFile file = new MockMultipartFile(fileName,fileName, fileName.substring(14,fileName.length()), input); |
| | | // UploadResult uploadResult = storage.upload(input,getPath(fileName),"multipart/form-data; charset=ISO-8859-1"); |
| | | UploadResult uploadResult; |
| | | // try { |
| | | uploadResult = storage.uploadSuffix2(fileBytesByName, getPath(fileName), "multipart/form-data; charset=ISO-8859-1"); |
| | | |
| | | 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); |
| | | input.close(); |
| | | // buildResultEntity(fileName, fileName.substring(14,fileName.length()), "minio", uploadResult, file, |
| | | // password, fileBytesByName); |
| | | |
| | | buildResultEntity(fileName, fileName.substring(14, fileName.length()), "minio", uploadResult, (MultipartFile)mockMultipartFile, password, fileBytesByName); |
| | | } |
| | | |
| | | } |