dev add check similar
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-29 17:41:41 +07:00
parent 67204d1c5c
commit 93da73e90b
2 changed files with 45 additions and 36 deletions
@@ -149,38 +149,24 @@ public class ImageFoundRequestHandler implements RequestHandler {
YandexSearchResponse.ImageResult image = allUniqueImages.getFirst(); YandexSearchResponse.ImageResult image = allUniqueImages.getFirst();
String url = image.getUrl(); String url = image.getUrl();
Path tempFile = null; Path tempFile = null;
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info(String.valueOf(image));
log.info(String.valueOf(image));
log.info(String.valueOf(image));
log.info(String.valueOf(image));
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info(image.getPageTitle());
log.info(image.getPageUrl());
log.info(image.getHost());
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info(url);
log.info(url);
log.info(url);
log.info(url);
log.info(url);
log.info(url);
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
try { try {
tempFile = fileUploadService.downloadImageFromUrl(url); tempFile = fileUploadService.downloadImageFromUrl(url);
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
log.info("tempFile: " + tempFile.toAbsolutePath());
String filePath = tempFile.toAbsolutePath().toString(); String filePath = tempFile.toAbsolutePath().toString();
@@ -614,15 +614,38 @@ public class FileUploadServiceImpl implements FileUploadService {
Path tempFile = Files.createTempFile("upload_check_", extension); Path tempFile = Files.createTempFile("upload_check_", extension);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0"); connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36");
connection.setConnectTimeout(5000); connection.setConnectTimeout(10000);
connection.setReadTimeout(10000); connection.setReadTimeout(10000);
connection.setInstanceFollowRedirects(true);
try {
int responseCode = connection.getResponseCode();
System.out.println("Response code: " + responseCode);
if (responseCode != 200) {
throw new IOException("Bad response code: " + responseCode);
}
try (InputStream in = connection.getInputStream()) { try (InputStream in = connection.getInputStream()) {
Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING); Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
} }
long size = Files.size(tempFile);
System.out.println("File downloaded: " + tempFile + ", size: " + size + " bytes");
if (size == 0) {
throw new IOException("Downloaded empty file");
}
return tempFile; return tempFile;
} catch (Exception e) {
Files.deleteIfExists(tempFile);
throw new IOException("Failed to download: " + urlString, e);
} finally {
connection.disconnect();
}
} }
private UploadProgressResponse handleExistingChunk(FileUploadSession session, private UploadProgressResponse handleExistingChunk(FileUploadSession session,