changeset 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 a25e74fad379
children 24ef02dc7a7a
files NEWS OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Apr 26 16:14:49 2022 +0200
+++ b/NEWS	Wed Apr 27 16:56:53 2022 +0200
@@ -41,6 +41,8 @@
 * new field "MainDicomTags" in the /system route response to list the tags that
   are saved in DB
 * new field "StorageCompression" reported in the /system route response
+* New option "filename" in "/.../{id}/archive" and "/.../{id}/media" to
+  manually set the filename in the "Content-Disposition" HTTP header
 
 
 Version 1.10.1 (2022-03-23)
--- 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);
   }