Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestApi.cpp @ 796:e7b1ca0f1e04
creation of dicom files
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 May 2014 12:09:11 +0200 |
parents | 5197fd35333c |
children | a811bdf8b8eb |
comparison
equal
deleted
inserted
replaced
795:d466b3606aca | 796:e7b1ca0f1e04 |
---|---|
30 **/ | 30 **/ |
31 | 31 |
32 | 32 |
33 #include "OrthancRestApi.h" | 33 #include "OrthancRestApi.h" |
34 | 34 |
35 #include "../DicomModification.h" | |
36 | |
35 #include <glog/logging.h> | 37 #include <glog/logging.h> |
36 | 38 |
37 namespace Orthanc | 39 namespace Orthanc |
38 { | 40 { |
41 void OrthancRestApi::AnswerStoredInstance(RestApi::PostCall& call, | |
42 const std::string& publicId, | |
43 StoreStatus status) | |
44 { | |
45 Json::Value result = Json::objectValue; | |
46 | |
47 if (status != StoreStatus_Failure) | |
48 { | |
49 result["ID"] = publicId; | |
50 result["Path"] = GetBasePath(ResourceType_Instance, publicId); | |
51 } | |
52 | |
53 result["Status"] = EnumerationToString(status); | |
54 call.GetOutput().AnswerJson(result); | |
55 } | |
56 | |
57 | |
58 | |
39 // Upload of DICOM files through HTTP --------------------------------------- | 59 // Upload of DICOM files through HTTP --------------------------------------- |
40 | 60 |
41 static void UploadDicomFile(RestApi::PostCall& call) | 61 static void UploadDicomFile(RestApi::PostCall& call) |
42 { | 62 { |
43 ServerContext& context = OrthancRestApi::GetContext(call); | 63 ServerContext& context = OrthancRestApi::GetContext(call); |
50 | 70 |
51 LOG(INFO) << "Receiving a DICOM file of " << postData.size() << " bytes through HTTP"; | 71 LOG(INFO) << "Receiving a DICOM file of " << postData.size() << " bytes through HTTP"; |
52 | 72 |
53 std::string publicId; | 73 std::string publicId; |
54 StoreStatus status = context.Store(publicId, postData); | 74 StoreStatus status = context.Store(publicId, postData); |
55 Json::Value result = Json::objectValue; | |
56 | 75 |
57 if (status != StoreStatus_Failure) | 76 OrthancRestApi::GetApi(call).AnswerStoredInstance(call, publicId, status); |
58 { | |
59 result["ID"] = publicId; | |
60 result["Path"] = GetBasePath(ResourceType_Instance, publicId); | |
61 } | |
62 | |
63 result["Status"] = EnumerationToString(status); | |
64 call.GetOutput().AnswerJson(result); | |
65 } | 77 } |
66 | 78 |
67 | 79 |
68 | 80 |
69 // Registration of the various REST handlers -------------------------------- | 81 // Registration of the various REST handlers -------------------------------- |