lordgamez commented on a change in pull request #1221:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1221#discussion_r783035680
##########
File path: extensions/azure/storage/AzureDataLakeStorage.cpp
##########
@@ -61,4 +61,29 @@ bool AzureDataLakeStorage::deleteFile(const
storage::DeleteAzureDataLakeStorageP
}
}
+std::optional<uint64_t> AzureDataLakeStorage::fetchFile(const
FetchAzureDataLakeStorageParameters& params, io::BaseStream& stream) {
+ try {
+ auto fetch_res = data_lake_storage_client_->fetchFile(params);
+
+ std::array<uint8_t, 4096> buffer;
+ size_t write_size = 0;
+ if (fetch_res.FileSize < 0) return 0;
+ while (write_size < gsl::narrow<uint64_t>(fetch_res.FileSize)) {
+ const auto next_write_size =
(std::min)(gsl::narrow<size_t>(fetch_res.FileSize) - write_size, buffer.size());
+ if (!fetch_res.Body->Read(buffer.data(),
gsl::narrow<std::streamsize>(next_write_size))) {
+ return -1;
+ }
+ const auto ret = stream.write(buffer.data(), next_write_size);
+ if (io::isError(ret)) {
+ return -1;
+ }
+ write_size += next_write_size;
+ }
Review comment:
Good idea, saves us some code duplication, updated in
714793593b09ed8b33ac7db2547c74258467e748
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]