# HG changeset patch # User Sebastien Jodogne # Date 1582625276 -3600 # Node ID e85bfba2d307b1d14ca2623d9de44395f8c9300f # Parent 9c091747483a78416528bf3c82cbc1135f6b9c32 "/instances": Support "Content-Encoding: gzip" to upload gzip-compressed DICOM files diff -r 9c091747483a -r e85bfba2d307 NEWS --- a/NEWS Tue Feb 25 10:51:26 2020 +0100 +++ b/NEWS Tue Feb 25 11:07:56 2020 +0100 @@ -12,6 +12,7 @@ * "/tools/log-level": Possibility to access and change the log level without restarting Orthanc * added "/instances/{id}/frames/{frame}/rendered" and "/instances/{id}/rendered" routes to render frames, taking windowing and resizing into account +* "/instances": Support "Content-Encoding: gzip" to upload gzip-compressed DICOM files Plugins ------- diff -r 9c091747483a -r e85bfba2d307 OrthancServer/OrthancRestApi/OrthancRestApi.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Tue Feb 25 10:51:26 2020 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Tue Feb 25 11:07:56 2020 +0100 @@ -34,11 +34,14 @@ #include "../PrecompiledHeadersServer.h" #include "OrthancRestApi.h" +#include "../../Core/Compression/GzipCompressor.h" #include "../../Core/Logging.h" #include "../../Core/MetricsRegistry.h" #include "../../Core/SerializationToolbox.h" #include "../ServerContext.h" +#include + namespace Orthanc { static void SetupResourceAnswer(Json::Value& result, @@ -118,13 +121,22 @@ "Received an empty DICOM file"); } - // TODO Remove unneccessary memcpy - std::string postData; - call.BodyToString(postData); + std::string dicom; + + if (boost::iequals(call.GetHttpHeader("content-encoding", ""), "gzip")) + { + GzipCompressor compressor; + compressor.Uncompress(dicom, call.GetBodyData(), call.GetBodySize()); + } + else + { + // TODO Remove unneccessary memcpy + call.BodyToString(dicom); + } DicomInstanceToStore toStore; toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); - toStore.SetBuffer(postData); + toStore.SetBuffer(dicom); std::string publicId; StoreStatus status = context.Store(publicId, toStore);