in src/main/java/com/epam/digital/data/platform/restapi/core/service/AbstractCsvProcessor.java [92:109]
private void validateContent(byte[] content, File fileDto) {
log.info("Validating csv file content");
var fileActualChecksum = DigestUtils.sha256Hex(content);
if (!StringUtils.equals(fileActualChecksum, fileDto.getChecksum())) {
throw new ChecksumInconsistencyException(
String.format(
"Checksum from ceph object (%s) and from request (%s) do not match. File id: '%s'",
fileActualChecksum, fileDto.getChecksum(), fileDto.getId()));
}
CharsetDetector charsetDetector = new CharsetDetector(content.length);
charsetDetector.setText(content);
var encoding = charsetDetector.detectAll()[0].getName();
if (!StringUtils.equals(encoding, StandardCharsets.UTF_8.name())) {
throw new CsvFileEncodingException(
"Wrong csv file encoding found instead of UTF-8: " + encoding);
}
}