comparison 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
comparison
equal deleted inserted replaced
1145:0479d02c6778 1146:200fcac0deb4
110 static void GetInstanceFile(RestApiGetCall& call) 110 static void GetInstanceFile(RestApiGetCall& call)
111 { 111 {
112 ServerContext& context = OrthancRestApi::GetContext(call); 112 ServerContext& context = OrthancRestApi::GetContext(call);
113 113
114 std::string publicId = call.GetUriComponent("id", ""); 114 std::string publicId = call.GetUriComponent("id", "");
115 context.AnswerDicomFile(call.GetOutput(), publicId, FileContentType_Dicom); 115 context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_Dicom);
116 } 116 }
117 117
118 118
119 static void ExportInstanceFile(RestApiPostCall& call) 119 static void ExportInstanceFile(RestApiPostCall& call)
120 { 120 {
136 { 136 {
137 ServerContext& context = OrthancRestApi::GetContext(call); 137 ServerContext& context = OrthancRestApi::GetContext(call);
138 138
139 std::string publicId = call.GetUriComponent("id", ""); 139 std::string publicId = call.GetUriComponent("id", "");
140 140
141 Json::Value full;
142 context.ReadJson(full, publicId);
143
144 if (simplify) 141 if (simplify)
145 { 142 {
143 Json::Value full;
144 context.ReadJson(full, publicId);
145
146 Json::Value simplified; 146 Json::Value simplified;
147 SimplifyTags(simplified, full); 147 SimplifyTags(simplified, full);
148 call.GetOutput().AnswerJson(simplified); 148 call.GetOutput().AnswerJson(simplified);
149 } 149 }
150 else 150 else
151 { 151 {
152 call.GetOutput().AnswerJson(full); 152 context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_DicomAsJson);
153 } 153 }
154 } 154 }
155 155
156 156
157 static void GetInstanceTagsBis(RestApiGetCall& call) 157 static void GetInstanceTagsBis(RestApiGetCall& call)
447 ServerContext& context = OrthancRestApi::GetContext(call); 447 ServerContext& context = OrthancRestApi::GetContext(call);
448 448
449 CheckValidResourceType(call); 449 CheckValidResourceType(call);
450 450
451 std::string publicId = call.GetUriComponent("id", ""); 451 std::string publicId = call.GetUriComponent("id", "");
452 std::string name = call.GetUriComponent("name", ""); 452 FileContentType type = StringToContentType(call.GetUriComponent("name", ""));
453 453
454 std::string content; 454 if (uncompress)
455 context.ReadFile(content, publicId, StringToContentType(name), 455 {
456 (uncompress == 1)); 456 context.AnswerAttachment(call.GetOutput(), publicId, type);
457 457 }
458 call.GetOutput().AnswerBuffer(content, "application/octet-stream"); 458 else
459 {
460 // Return the raw data (possibly compressed), as stored on the filesystem
461 std::string content;
462 context.ReadFile(content, publicId, type, false);
463 call.GetOutput().AnswerBuffer(content, "application/octet-stream");
464 }
459 } 465 }
460 466
461 467
462 static void GetAttachmentSize(RestApiGetCall& call) 468 static void GetAttachmentSize(RestApiGetCall& call)
463 { 469 {