I am trying to copy a file in the datalake from a path to another. My previous code which is
public void enableFileSelected (String sourcePath, String destPath, String fileSystemName) throws IOException {
log.debug("enableFileSelected");
log.debug("enableFileSelected sourcePath : {}", sourcePath);
log.debug("enableFileSelected destPath : {}", destPath);
log.debug("enableFileSelected containerName : {}", fileSystemName);
DataLakeFileSystemClient fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
log.debug("fileSystemClient1 : {}", fileSystemClient);
DataLakeFileClient sourcefileClient = fileSystemClient.getFileClient(sourcePath);
log.debug("sourcefileClient : {}", sourcefileClient);
InputStream inputStream = sourcefileClient.openInputStream().getInputStream();
DataLakeFileClient destfileClient = fileSystemClient.getFileClient(destPath);
log.debug("destfileClient : {}", destfileClient);
byte[] content = StreamUtils.copyToByteArray(inputStream);
ByteArrayInputStream contentStream = new ByteArrayInputStream(content);
destfileClient.upload(contentStream, content.length,true);
}
worked fine, the only problem is that the heap may get full and the app crashes. To fix that I have tried using streams and temp files. Temp files are blocked due to security reasons. With streams I am receiving error nested exception is java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-html My current code is
public void enableFileSelected (String sourcePath, String destPath, String fileSystemName) throws IOException {
log.debug("enableFileSelected");
log.debug("enableFileSelected sourcePath : {}", sourcePath);
log.debug("enableFileSelected destPath : {}", destPath);
log.debug("enableFileSelected containerName : {}", fileSystemName);
DataLakeFileSystemClient fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
log.debug("fileSystemClient1 : {}", fileSystemClient);
DataLakeFileClient sourcefileClient = fileSystemClient.getFileClient(sourcePath);
log.debug("sourcefileClient : {}", sourcefileClient);
DataLakeFileClient destfileClient = fileSystemClient.getFileClient(destPath);
try (InputStream inputStream = sourcefileClient.openInputStream().getInputStream()) {
long fileLength = sourcefileClient.getProperties().getFileSize();
log.debug("sourcefileClientLength : {}", fileLength);
log.debug("destfileClient : {}", destfileClient);
destfileClient.upload(inputStream, fileLength, true);
}
}
I do have some workarounds but I would rather fix this function if possible