|
@@ -121,28 +121,30 @@ public class DataService {
|
|
|
.withEndpointConfiguration(endpointConfiguration)
|
|
|
.withCredentials(credentialsProvider).build();
|
|
|
|
|
|
- String fileNameStr[] = filePath.split("=");
|
|
|
- String fileName = fileNameStr[fileNameStr.length - 2];
|
|
|
- String fileStorePath = getFileWithUrl(filePath, fileName);
|
|
|
+ String fileNameStr[] = filePath.split("/");
|
|
|
+ String fileName = fileNameStr[fileNameStr.length - 3]+".jpg";
|
|
|
+ String fpString = fileNameStr[fileNameStr.length - 4]+"/"+fileNameStr[fileNameStr.length - 3]+"/"+fileNameStr[fileNameStr.length - 2]+"/"+fileNameStr[fileNameStr.length - 1];
|
|
|
+// String fileStorePath = getFileWithUrl(fpString, fileName);
|
|
|
+ String fileStorePath = downloadFtpFile(fpString, fileName);
|
|
|
File file = new File(fileStorePath);
|
|
|
String key = PropKit.get("institution_id") + "/" + fileName;
|
|
|
|
|
|
- boolean exists = client.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
- if (!exists) {
|
|
|
- PutObjectRequest request = new PutObjectRequest(PropKit.get("oss_bucketName"), key, file);
|
|
|
- request.setCannedAcl(CannedAccessControlList.PublicRead);
|
|
|
- client.putObject(request);
|
|
|
- boolean bexists = client.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
- if (!bexists) {
|
|
|
- PutObjectRequest request2 = new PutObjectRequest(PropKit.get("oss_bucketName"), key, file);
|
|
|
- request.setCannedAcl(CannedAccessControlList.PublicRead);
|
|
|
- client.putObject(request);
|
|
|
- }
|
|
|
- }
|
|
|
- client.shutdown();
|
|
|
- map.put("url", "https://annex.eos.jinan-4.cmecloud.cn/" + key);
|
|
|
- map.put("name", key);
|
|
|
- postWithParameters(SAVE_ANNEX_URL, map);
|
|
|
+// boolean exists = client.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
+// if (!exists) {
|
|
|
+// PutObjectRequest request = new PutObjectRequest(PropKit.get("oss_bucketName"), key, file);
|
|
|
+// request.setCannedAcl(CannedAccessControlList.PublicRead);
|
|
|
+// client.putObject(request);
|
|
|
+// boolean bexists = client.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
+// if (!bexists) {
|
|
|
+// PutObjectRequest request2 = new PutObjectRequest(PropKit.get("oss_bucketName"), key, file);
|
|
|
+// request.setCannedAcl(CannedAccessControlList.PublicRead);
|
|
|
+// client.putObject(request);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// client.shutdown();
|
|
|
+// map.put("url", "https://annex.eos.jinan-4.cmecloud.cn/" + key);
|
|
|
+// map.put("name", key);
|
|
|
+// postWithParameters(SAVE_ANNEX_URL, map);
|
|
|
|
|
|
file.delete();
|
|
|
|
|
@@ -173,37 +175,6 @@ public class DataService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static String getFileWithUrl(String url, String filename) {
|
|
|
-
|
|
|
- Request request = new Request.Builder().url(url).build();
|
|
|
- try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
|
|
|
- if (!response.isSuccessful())
|
|
|
- throw new IOException("Unexpected code " + response);
|
|
|
- InputStream inputStream = response.body().source().inputStream();
|
|
|
- // 本地文件夹目录(下载位置)
|
|
|
- String folder = PropKit.get("oss_localPath");
|
|
|
- // 下载文件保存位置
|
|
|
- String savepath = folder + "/" + filename;
|
|
|
- BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(new File(savepath)));
|
|
|
- byte[] data = new byte[1024];
|
|
|
- int len;
|
|
|
- int available = inputStream.available();
|
|
|
- while ((len = inputStream.read(data)) != -1) {
|
|
|
- bufferedOutputStream.write(data, 0, len);
|
|
|
- }
|
|
|
- bufferedOutputStream.flush();
|
|
|
- bufferedOutputStream.close();
|
|
|
- inputStream.close();
|
|
|
-
|
|
|
- return savepath;
|
|
|
-
|
|
|
- } catch (IOException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- return "";
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
//ftp://FTPUser:ftpuser@188.188.2.1:6161/20240726/1AFB48FCF39241AA8DE61F85EE6D847F/Report/Report.jpg"
|
|
|
public String downloadFtpFile(String remoteFileName, String fileName) {
|
|
|
FTPClient ftpClient = new FTPClient();
|