Github user minifirocks commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/146#discussion_r143551961 --- Diff: libminifi/src/processors/MergeContent.cpp --- @@ -276,6 +287,46 @@ std::shared_ptr<core::FlowFile> BinaryConcatenationMerge::merge(core::ProcessCon return flowFile; } +std::shared_ptr<core::FlowFile> TarMerge::merge(core::ProcessContext *context, core::ProcessSession *session, std::deque<std::shared_ptr<core::FlowFile>> &flows, std::string &header, + std::string &footer, std::string &demarcator) { + std::shared_ptr<FlowFileRecord> flowFile = std::static_pointer_cast < FlowFileRecord > (session->create()); + ArchiveMerge::WriteCallback callback(std::string(MERGE_FORMAT_TAR_VALUE), flows, session); + session->write(flowFile, &callback); + session->putAttribute(flowFile, FlowAttributeKey(MIME_TYPE), this->getMergedContentType()); + std::string fileName; + flowFile->getAttribute(FlowAttributeKey(FILENAME), fileName); + if (flows.size() == 1) { + flows.front()->getAttribute(FlowAttributeKey(FILENAME), fileName); + } else { + flows.front()->getAttribute(BinFiles::SEGMENT_ORIGINAL_FILENAME, fileName); + } + if (!fileName.empty()) { + fileName += ".tar"; + session->putAttribute(flowFile, FlowAttributeKey(FILENAME), fileName); + } + return flowFile; +} + +std::shared_ptr<core::FlowFile> ZipMerge::merge(core::ProcessContext *context, core::ProcessSession *session, std::deque<std::shared_ptr<core::FlowFile>> &flows, std::string &header, + std::string &footer, std::string &demarcator) { + std::shared_ptr<FlowFileRecord> flowFile = std::static_pointer_cast < FlowFileRecord > (session->create()); + ArchiveMerge::WriteCallback callback(std::string(MERGE_FORMAT_ZIP_VALUE), flows, session); + session->write(flowFile, &callback); + session->putAttribute(flowFile, FlowAttributeKey(MIME_TYPE), this->getMergedContentType()); + std::string fileName; + flowFile->getAttribute(FlowAttributeKey(FILENAME), fileName); + if (flows.size() == 1) { + flows.front()->getAttribute(FlowAttributeKey(FILENAME), fileName); + } else { + flows.front()->getAttribute(BinFiles::SEGMENT_ORIGINAL_FILENAME, fileName); + } + if (!fileName.empty()) { + fileName += ".zip"; --- End diff -- yes, we will zip the two separate zip into a larger one
---