diff OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp @ 4987:48b53ac404d9

New option "filename" in "/.../{id}/archive" and "/.../{id}/media"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 27 Apr 2022 16:56:53 +0200
parents df86d2505df8
children c387ebeb67b5
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp	Tue Apr 26 16:14:49 2022 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp	Wed Apr 27 16:56:53 2022 +0200
@@ -580,6 +580,7 @@
   static void CreateSingleGet(RestApiGetCall& call)
   {
     static const char* const TRANSCODE = "transcode";
+    static const char* const FILENAME = "filename";
 
     if (call.IsDocumentation())
     {
@@ -594,6 +595,9 @@
                         "which might *not* be desirable to archive large amount of data, as it might "
                         "lead to network timeouts. Prefer the asynchronous version using `POST` method.")
         .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest")
+        .SetHttpGetArgument(FILENAME, RestApiCallDocumentation::Type_String,
+                            "Filename to set in the \"Content-Disposition\" HTTP header "
+                            "(including file extension)", false)
         .SetHttpGetArgument(TRANSCODE, RestApiCallDocumentation::Type_String,
                             "If present, the DICOM files in the archive will be transcoded to the provided "
                             "transfer syntax: https://book.orthanc-server.com/faq/transcoding.html", false)
@@ -609,7 +613,8 @@
 
     ServerContext& context = OrthancRestApi::GetContext(call);
 
-    std::string id = call.GetUriComponent("id", "");
+    const std::string id = call.GetUriComponent("id", "");
+    const std::string filename = call.GetArgument(FILENAME, id + ".zip");  // New in Orthanc 1.11.0
 
     bool extended;
     if (IS_MEDIA)
@@ -636,7 +641,7 @@
     }
 
     SubmitJob(call.GetOutput(), context, job, 0 /* priority */,
-              true /* synchronous */, id + ".zip");
+              true /* synchronous */, filename);
   }