Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-30353 Export SDS data using PTree content streaming #17814

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions esp/services/ws_dali/ws_daliservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ using namespace daadmin;

#define REQPATH_EXPORTSDSDATA "/WSDali/Export"

const char* daliFolder = "tempdalifiles" PATHSEPSTR;
const unsigned daliFolderLength = strlen(daliFolder);

void CWSDaliEx::init(IPropertyTree* cfg, const char* process, const char* service)
{
espProcess.set(process);
Expand Down Expand Up @@ -74,29 +71,18 @@ void CWSDaliSoapBindingEx::exportSDSData(CHttpRequest* request, CHttpResponse* r
throw makeStringException(ECLWATCH_CANNOT_CONNECT_DALI, "Failed to connect Dali.");

Owned<IPropertyTree> root = conn->getRoot();
response->setContent(root);

Owned<IFile> workingDir = createIFile(daliFolder);
if (!workingDir->exists())
workingDir->createDirectory();

StringBuffer peer, outFileNameWithPath;
VStringBuffer prefix("sds_for_%s", request->getPeer(peer).str());
Owned<IFileIO> io = createUniqueFile(daliFolder, prefix, nullptr, outFileNameWithPath, IFOcreaterw);
{ //Force the fios to finish
Owned<IFileIOStream> fios = createBufferedIOStream(io);
toXML(root, *fios);
}

VStringBuffer headerStr("attachment;filename=%s", outFileNameWithPath.str() + daliFolderLength);
//Set "Content-disposition" header
CDateTime dt;
dt.setNow();
StringBuffer headerStr;
headerStr.appendf("attachment;filename=sds_%u.%u.tmp", (unsigned)GetCurrentProcessId(), (unsigned)dt.getSimple());
IEspContext* context = request->queryContext();
context->addCustomerHeader("Content-disposition", headerStr.str());

response->setContent(createIOStream(io));
response->setContentType(HTTP_TYPE_OCTET_STREAM);
response->send();

io.clear();
removeFileTraceIfFail(outFileNameWithPath);
}

void CWSDaliEx::checkAccess(IEspContext& context)
Expand Down
Loading