public boolean store()

in src/main/java/com/epam/digital/data/platform/restapi/core/service/FileService.java [58:87]


  public boolean store(String instanceId, File file) {
    if (fileProcessing.isEnabled()) {
      log.info("Storing file '{}' from lowcode to data ceph bucket", file.getId());

      var lowcodeId = fileKeyProvider.generateKey(instanceId, file.getId());

      FileDataDto fileDataDto;
      try {
        fileDataDto = lowcodeFileDataStorageService.loadByKey(lowcodeId);
      } catch (FileNotFoundException ex) {
        log.warn("File not found ", ex);
        return false;
      }

      var content = getContent(fileDataDto.getContent());
      var calculatedChecksum = DigestUtils.sha256Hex(content);

      if (!StringUtils.equals(calculatedChecksum, file.getChecksum())) {
        throw new ChecksumInconsistencyException(
            String.format(
                "Checksum from ceph object (%s) and from request (%s) do not match. File id: '%s'",
                calculatedChecksum, file.getChecksum(), file.getId()));
      }

      fileDataDto.setContent(new ByteArrayInputStream(content));
      datafactoryFileDataStorageService.save(file.getId(), fileDataDto);
    }

    return true;
  }