Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
4986:a25e74fad379 | 4987:48b53ac404d9 |
---|---|
578 | 578 |
579 template <bool IS_MEDIA> | 579 template <bool IS_MEDIA> |
580 static void CreateSingleGet(RestApiGetCall& call) | 580 static void CreateSingleGet(RestApiGetCall& call) |
581 { | 581 { |
582 static const char* const TRANSCODE = "transcode"; | 582 static const char* const TRANSCODE = "transcode"; |
583 static const char* const FILENAME = "filename"; | |
583 | 584 |
584 if (call.IsDocumentation()) | 585 if (call.IsDocumentation()) |
585 { | 586 { |
586 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str()); | 587 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str()); |
587 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */); | 588 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */); |
592 .SetDescription("Synchronously create a " + m + " containing the DICOM " + r + | 593 .SetDescription("Synchronously create a " + m + " containing the DICOM " + r + |
593 " whose Orthanc identifier is provided in the URL. This flavor is synchronous, " | 594 " whose Orthanc identifier is provided in the URL. This flavor is synchronous, " |
594 "which might *not* be desirable to archive large amount of data, as it might " | 595 "which might *not* be desirable to archive large amount of data, as it might " |
595 "lead to network timeouts. Prefer the asynchronous version using `POST` method.") | 596 "lead to network timeouts. Prefer the asynchronous version using `POST` method.") |
596 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest") | 597 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest") |
598 .SetHttpGetArgument(FILENAME, RestApiCallDocumentation::Type_String, | |
599 "Filename to set in the \"Content-Disposition\" HTTP header " | |
600 "(including file extension)", false) | |
597 .SetHttpGetArgument(TRANSCODE, RestApiCallDocumentation::Type_String, | 601 .SetHttpGetArgument(TRANSCODE, RestApiCallDocumentation::Type_String, |
598 "If present, the DICOM files in the archive will be transcoded to the provided " | 602 "If present, the DICOM files in the archive will be transcoded to the provided " |
599 "transfer syntax: https://book.orthanc-server.com/faq/transcoding.html", false) | 603 "transfer syntax: https://book.orthanc-server.com/faq/transcoding.html", false) |
600 .AddAnswerType(MimeType_Zip, "ZIP file containing the archive"); | 604 .AddAnswerType(MimeType_Zip, "ZIP file containing the archive"); |
601 if (IS_MEDIA) | 605 if (IS_MEDIA) |
607 return; | 611 return; |
608 } | 612 } |
609 | 613 |
610 ServerContext& context = OrthancRestApi::GetContext(call); | 614 ServerContext& context = OrthancRestApi::GetContext(call); |
611 | 615 |
612 std::string id = call.GetUriComponent("id", ""); | 616 const std::string id = call.GetUriComponent("id", ""); |
617 const std::string filename = call.GetArgument(FILENAME, id + ".zip"); // New in Orthanc 1.11.0 | |
613 | 618 |
614 bool extended; | 619 bool extended; |
615 if (IS_MEDIA) | 620 if (IS_MEDIA) |
616 { | 621 { |
617 extended = call.HasArgument("extended"); | 622 extended = call.HasArgument("extended"); |
634 unsigned int loaderThreads = lock.GetConfiguration().GetUnsignedIntegerParameter(CONFIG_LOADER_THREADS, 0); // New in Orthanc 1.10.0 | 639 unsigned int loaderThreads = lock.GetConfiguration().GetUnsignedIntegerParameter(CONFIG_LOADER_THREADS, 0); // New in Orthanc 1.10.0 |
635 job->SetLoaderThreads(loaderThreads); | 640 job->SetLoaderThreads(loaderThreads); |
636 } | 641 } |
637 | 642 |
638 SubmitJob(call.GetOutput(), context, job, 0 /* priority */, | 643 SubmitJob(call.GetOutput(), context, job, 0 /* priority */, |
639 true /* synchronous */, id + ".zip"); | 644 true /* synchronous */, filename); |
640 } | 645 } |
641 | 646 |
642 | 647 |
643 template <bool IS_MEDIA> | 648 template <bool IS_MEDIA> |
644 static void CreateSinglePost(RestApiPostCall& call) | 649 static void CreateSinglePost(RestApiPostCall& call) |