Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5080:d7274e43ea7c attach-custom-data
allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 08 Sep 2022 17:42:08 +0200 |
parents | e69a3ff39bc5 |
children |
comparison
equal
deleted
inserted
replaced
5079:4366b4c41441 | 5080:d7274e43ea7c |
---|---|
2391 ServerContext& context = OrthancRestApi::GetContext(call); | 2391 ServerContext& context = OrthancRestApi::GetContext(call); |
2392 CheckValidResourceType(call); | 2392 CheckValidResourceType(call); |
2393 | 2393 |
2394 std::string publicId = call.GetUriComponent("id", ""); | 2394 std::string publicId = call.GetUriComponent("id", ""); |
2395 std::string name = call.GetUriComponent("name", ""); | 2395 std::string name = call.GetUriComponent("name", ""); |
2396 ResourceType resourceType = StringToResourceType(call.GetFullUri()[0].c_str()); | |
2396 | 2397 |
2397 FileContentType contentType = StringToContentType(name); | 2398 FileContentType contentType = StringToContentType(name); |
2398 if (IsUserContentType(contentType)) // It is forbidden to modify internal attachments | 2399 if (IsUserContentType(contentType)) // It is forbidden to modify internal attachments |
2399 { | 2400 { |
2400 int64_t oldRevision; | 2401 int64_t oldRevision; |
2414 oldMD5.clear(); // dummy value | 2415 oldMD5.clear(); // dummy value |
2415 } | 2416 } |
2416 } | 2417 } |
2417 | 2418 |
2418 int64_t newRevision; | 2419 int64_t newRevision; |
2419 context.AddAttachment(newRevision, publicId, StringToContentType(name), call.GetBodyData(), | 2420 context.AddAttachment(newRevision, publicId, resourceType, StringToContentType(name), call.GetBodyData(), |
2420 call.GetBodySize(), hasOldRevision, oldRevision, oldMD5); | 2421 call.GetBodySize(), hasOldRevision, oldRevision, oldMD5); |
2421 | 2422 |
2422 SetBufferContentETag(call.GetOutput(), newRevision, call.GetBodyData(), call.GetBodySize()); // New in Orthanc 1.9.2 | 2423 SetBufferContentETag(call.GetOutput(), newRevision, call.GetBodyData(), call.GetBodySize()); // New in Orthanc 1.9.2 |
2423 call.GetOutput().AnswerBuffer("{}", MimeType_Json); | 2424 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
2424 } | 2425 } |
2534 | 2535 |
2535 CheckValidResourceType(call); | 2536 CheckValidResourceType(call); |
2536 | 2537 |
2537 std::string publicId = call.GetUriComponent("id", ""); | 2538 std::string publicId = call.GetUriComponent("id", ""); |
2538 std::string name = call.GetUriComponent("name", ""); | 2539 std::string name = call.GetUriComponent("name", ""); |
2540 ResourceType resourceType = StringToResourceType(call.GetFullUri()[0].c_str()); | |
2539 FileContentType contentType = StringToContentType(name); | 2541 FileContentType contentType = StringToContentType(name); |
2540 | 2542 |
2541 OrthancRestApi::GetContext(call).ChangeAttachmentCompression(publicId, contentType, compression); | 2543 OrthancRestApi::GetContext(call).ChangeAttachmentCompression(publicId, resourceType, contentType, compression); |
2542 call.GetOutput().AnswerBuffer("{}", MimeType_Json); | 2544 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
2543 } | 2545 } |
2544 | 2546 |
2545 | 2547 |
2546 static void IsAttachmentCompressed(RestApiGetCall& call) | 2548 static void IsAttachmentCompressed(RestApiGetCall& call) |