# HG changeset patch # User Alain Mazy # Date 1644408611 -3600 # Node ID 504624b0a0628caf56dd82da0e5ea850b8680a1b # Parent 6971ea27a2a909ddc9c084ad8d370808c3c025bb Added "/patients|studies|series|instances/{...}/attachments/{...}/info" route to retrieve the full information about an attachment (size, type, MD5 and UUID) diff -r 6971ea27a2a9 -r 504624b0a062 NEWS --- a/NEWS Mon Jan 31 17:22:05 2022 +0100 +++ b/NEWS Wed Feb 09 13:10:11 2022 +0100 @@ -34,7 +34,10 @@ * "/instances/{...}/frames/{...}/numpy": Download the frame as a Python numpy array * "/instances/{...}/numpy": Download the instance as a Python numpy array * "/series/{...}/numpy": Download the series as a Python numpy array -* Added a ?full option to "/patients|studies|series|instances/{...}/attachments route +* Added a ?full option to "/patients|studies|series|instances/{...}/attachments" route + to show the mapping alias<->numerical id. +* Added "/patients|studies|series|instances/{...}/attachments/{...}/info" route to retrieve + the full information about an attachment (size, type, MD5 and UUID) Lua --- diff -r 6971ea27a2a9 -r 504624b0a062 OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Mon Jan 31 17:22:05 2022 +0100 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Wed Feb 09 13:10:11 2022 +0100 @@ -2048,6 +2048,7 @@ operations.append("compressed-size"); operations.append("data"); + operations.append("info"); operations.append("is-compressed"); if (info.GetUncompressedMD5() != "") @@ -2064,6 +2065,8 @@ operations.append("verify-md5"); } + operations.append("uuid"); + call.GetOutput().AnswerJson(operations); } } @@ -2151,6 +2154,36 @@ } } + static void GetAttachmentInfo(RestApiGetCall& call) + { + if (call.IsDocumentation()) + { + ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str()); + std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */); + AddAttachmentDocumentation(call, r); + call.GetDocumentation() + .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */)) + .SetSummary("Get info about the attachment") + .SetDescription("Get all the information about the attachment associated with the given " + r) + .AddAnswerType(MimeType_Json, "JSON object containing the information about the attachment") + .SetHttpGetSample("https://demo.orthanc-server.com/instances/7c92ce8e-bbf67ed2-ffa3b8c1-a3b35d94-7ff3ae26/dicom/info", true); + return; + } + + FileInfo info; + if (GetAttachmentInfo(info, call)) + { + Json::Value result = Json::objectValue; + result["Uuid"] = info.GetUuid(); + result["ContentType"] = info.GetContentType(); + result["UncompressedSize"] = Json::Value::UInt64(info.GetUncompressedSize()); + result["CompressedSize"] = Json::Value::UInt64(info.GetCompressedSize()); + result["UncompressedMD5"] = info.GetUncompressedMD5(); + result["CompressedMD5"] = info.GetCompressedMD5(); + + call.GetOutput().AnswerJson(result); + } + } static void GetAttachmentCompressedSize(RestApiGetCall& call) { @@ -3696,6 +3729,7 @@ Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/md5", GetAttachmentMD5); Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/size", GetAttachmentSize); Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/uncompress", ChangeAttachmentCompression); + Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/info", GetAttachmentInfo); Register("/" + resourceTypes[i] + "/{id}/attachments/{name}/verify-md5", VerifyAttachment); }