Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestApi.cpp @ 3848:44bfcfdf42e8 transcoding
integration mainline->transcoding
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 20 Apr 2020 14:04:14 +0200 |
parents | 023b2a9f3aa1 be7df7fe3d80 |
children | 7610af1532c3 |
comparison
equal
deleted
inserted
replaced
3839:5bba4d249422 | 3848:44bfcfdf42e8 |
---|---|
119 { | 119 { |
120 throw OrthancException(ErrorCode_BadFileFormat, | 120 throw OrthancException(ErrorCode_BadFileFormat, |
121 "Received an empty DICOM file"); | 121 "Received an empty DICOM file"); |
122 } | 122 } |
123 | 123 |
124 // The lifetime of "dicom" must be longer than "toStore", as the | |
125 // latter can possibly store a reference to the former (*) | |
124 std::string dicom; | 126 std::string dicom; |
127 | |
128 DicomInstanceToStore toStore; | |
129 toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); | |
125 | 130 |
126 if (boost::iequals(call.GetHttpHeader("content-encoding", ""), "gzip")) | 131 if (boost::iequals(call.GetHttpHeader("content-encoding", ""), "gzip")) |
127 { | 132 { |
128 GzipCompressor compressor; | 133 GzipCompressor compressor; |
129 compressor.Uncompress(dicom, call.GetBodyData(), call.GetBodySize()); | 134 compressor.Uncompress(dicom, call.GetBodyData(), call.GetBodySize()); |
135 toStore.SetBuffer(dicom.c_str(), dicom.size()); // (*) | |
130 } | 136 } |
131 else | 137 else |
132 { | 138 { |
133 // TODO Remove unneccessary memcpy | 139 toStore.SetBuffer(call.GetBodyData(), call.GetBodySize()); |
134 call.BodyToString(dicom); | 140 } |
135 } | |
136 | |
137 DicomInstanceToStore toStore; | |
138 toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); | |
139 toStore.SetBuffer(dicom); | |
140 | 141 |
141 std::string publicId; | 142 std::string publicId; |
142 StoreStatus status = context.Store(publicId, toStore, StoreInstanceMode_Default); | 143 StoreStatus status = context.Store(publicId, toStore, StoreInstanceMode_Default); |
143 | 144 |
144 OrthancRestApi::GetApi(call).AnswerStoredInstance(call, toStore, status); | 145 OrthancRestApi::GetApi(call).AnswerStoredInstance(call, toStore, status); |