NCBACK-3
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-01-09 23:41:19 +07:00
parent edd508e5d8
commit b3a3d57ee3
2 changed files with 9 additions and 16 deletions
@@ -1,14 +0,0 @@
package ru.soune.nocopy.configuration.file;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "yandex")
public class YandexConfig {
private String apiKey;
private String folderId;
private String searchUrl;
}
@@ -54,6 +54,7 @@ public class YandexSearchService {
MessageCode.FILE_NOT_FOUND.getCode(), MessageCode.FILE_NOT_FOUND.getDescription(),
Map.of("fileId",fileId)));
});
byte[] fileBytes;
if (!isImageFile(fileEntity)) {
log.error("File not image: {}", fileEntity.getMimeType());
@@ -62,7 +63,14 @@ public class YandexSearchService {
Map.of("file_type", fileEntity.getMimeType())));
}
byte[] fileBytes = readFileFromDisk(fileEntity);
try {
fileBytes = readFileFromDisk(fileEntity);
} catch (IOException e) {
throw new NotValidFieldException("File not found or cannot read file", new BaseResponse(20007,
MessageCode.FILE_NOT_FOUND.getCode(), MessageCode.FILE_NOT_FOUND.getDescription(),
Map.of("fileId", fileId,
"filePath", fileEntity.getFilePath())));
}
return callYandexApi(fileBytes);
}
@@ -99,7 +107,6 @@ public class YandexSearchService {
connection.setRequestProperty("Authorization", "Api-Key " + apiKey);
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Accept", "application/json");
// connection.setRequestProperty("User-Agent", "Mozilla/5.0");
connection.setConnectTimeout(30000);
connection.setReadTimeout(30000);
connection.setDoOutput(true);