Mercurial > hg > orthanc
diff OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1146:200fcac0deb4
optimization for access to attachments
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 11 Sep 2014 14:04:48 +0200 |
parents | 0479d02c6778 |
children | 1ea4094d077c a921e3b5e763 |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Thu Sep 11 13:06:16 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Thu Sep 11 14:04:48 2014 +0200 @@ -112,7 +112,7 @@ ServerContext& context = OrthancRestApi::GetContext(call); std::string publicId = call.GetUriComponent("id", ""); - context.AnswerDicomFile(call.GetOutput(), publicId, FileContentType_Dicom); + context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_Dicom); } @@ -138,18 +138,18 @@ std::string publicId = call.GetUriComponent("id", ""); - Json::Value full; - context.ReadJson(full, publicId); - if (simplify) { + Json::Value full; + context.ReadJson(full, publicId); + Json::Value simplified; SimplifyTags(simplified, full); call.GetOutput().AnswerJson(simplified); } else { - call.GetOutput().AnswerJson(full); + context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_DicomAsJson); } } @@ -449,13 +449,19 @@ CheckValidResourceType(call); std::string publicId = call.GetUriComponent("id", ""); - std::string name = call.GetUriComponent("name", ""); + FileContentType type = StringToContentType(call.GetUriComponent("name", "")); - std::string content; - context.ReadFile(content, publicId, StringToContentType(name), - (uncompress == 1)); - - call.GetOutput().AnswerBuffer(content, "application/octet-stream"); + if (uncompress) + { + context.AnswerAttachment(call.GetOutput(), publicId, type); + } + else + { + // Return the raw data (possibly compressed), as stored on the filesystem + std::string content; + context.ReadFile(content, publicId, type, false); + call.GetOutput().AnswerBuffer(content, "application/octet-stream"); + } }