Mercurial > hg > orthanc-stl
comparison Sources/Plugin.cpp @ 55:41e3b79e7f4b nexus
added check of Nexus magic header
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 21 May 2024 15:19:08 +0200 |
parents | 83b1abee3ece |
children | c322c949bd8e |
comparison
equal
deleted
inserted
replaced
54:7b7e97724914 | 55:41e3b79e7f4b |
---|---|
947 { | 947 { |
948 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest, | 948 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest, |
949 "POST body missing string field \"" + std::string(KEY_CONTENT) + "\""); | 949 "POST body missing string field \"" + std::string(KEY_CONTENT) + "\""); |
950 } | 950 } |
951 | 951 |
952 std::string decoded; | |
953 Orthanc::Toolbox::DecodeBase64(decoded, body[KEY_CONTENT].asString()); | |
954 | |
955 if (decoded.size() < 4 || | |
956 decoded[0] != 0x20 || | |
957 decoded[1] != 0x73 || | |
958 decoded[2] != 0x78 || | |
959 decoded[3] != 0x4e) | |
960 { | |
961 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, | |
962 "This is not a valid Nexus file, its magic header is incorrect"); | |
963 } | |
964 | |
952 Json::Value creationBody = Json::objectValue; | 965 Json::Value creationBody = Json::objectValue; |
953 | 966 |
954 creationBody[KEY_TAGS] = body[KEY_TAGS]; | 967 creationBody[KEY_TAGS] = body[KEY_TAGS]; |
955 creationBody[KEY_TAGS][Orthanc::DICOM_TAG_MANUFACTURER.Format()] = ORTHANC_STL_MANUFACTURER; | 968 creationBody[KEY_TAGS][Orthanc::DICOM_TAG_MANUFACTURER.Format()] = ORTHANC_STL_MANUFACTURER; |
956 creationBody[KEY_TAGS][Orthanc::DICOM_TAG_SOP_CLASS_UID.Format()] = "1.2.840.10008.5.1.4.1.1.66"; | 969 creationBody[KEY_TAGS][Orthanc::DICOM_TAG_SOP_CLASS_UID.Format()] = "1.2.840.10008.5.1.4.1.1.66"; |