comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5426:c65e036d649b

StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
author Alain Mazy <am@osimis.io>
date Thu, 16 Nov 2023 16:09:04 +0100
parents 630d0195e3bb
children 111e21b4f8bc
comparison
equal deleted inserted replaced
5425:e2c9f9d9700e 5426:c65e036d649b
359 359
360 // Get information about a single instance ---------------------------------- 360 // Get information about a single instance ----------------------------------
361 361
362 static void GetInstanceFile(RestApiGetCall& call) 362 static void GetInstanceFile(RestApiGetCall& call)
363 { 363 {
364 static const char* const TRANSCODE = "transcode";
365
364 if (call.IsDocumentation()) 366 if (call.IsDocumentation())
365 { 367 {
366 call.GetDocumentation() 368 call.GetDocumentation()
367 .SetTag("Instances") 369 .SetTag("Instances")
368 .SetSummary("Download DICOM") 370 .SetSummary("Download DICOM")
369 .SetDescription("Download one DICOM instance") 371 .SetDescription("Download one DICOM instance")
370 .SetUriArgument("id", "Orthanc identifier of the DICOM instance of interest") 372 .SetUriArgument("id", "Orthanc identifier of the DICOM instance of interest")
371 .SetHttpHeader("Accept", "This HTTP header can be set to retrieve the DICOM instance in DICOMweb format") 373 .SetHttpHeader("Accept", "This HTTP header can be set to retrieve the DICOM instance in DICOMweb format")
374 .SetHttpGetArgument(TRANSCODE, RestApiCallDocumentation::Type_String,
375 "If present, the DICOM file will be transcoded to the provided "
376 "transfer syntax: https://book.orthanc-server.com/faq/transcoding.html", false)
372 .AddAnswerType(MimeType_Dicom, "The DICOM instance") 377 .AddAnswerType(MimeType_Dicom, "The DICOM instance")
373 .AddAnswerType(MimeType_DicomWebJson, "The DICOM instance, in DICOMweb JSON format") 378 .AddAnswerType(MimeType_DicomWebJson, "The DICOM instance, in DICOMweb JSON format")
374 .AddAnswerType(MimeType_DicomWebXml, "The DICOM instance, in DICOMweb XML format"); 379 .AddAnswerType(MimeType_DicomWebXml, "The DICOM instance, in DICOMweb XML format");
375 return; 380 return;
376 } 381 }
415 catch (OrthancException&) 420 catch (OrthancException&)
416 { 421 {
417 } 422 }
418 } 423 }
419 424
420 context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_Dicom); 425 if (call.HasArgument(TRANSCODE))
426 {
427 std::string source;
428 std::string transcoded;
429 context.ReadDicom(source, publicId);
430
431 if (context.TranscodeWithCache(transcoded, source, publicId, GetTransferSyntax(call.GetArgument(TRANSCODE, ""))))
432 {
433 call.GetOutput().AnswerBuffer(transcoded, MimeType_Dicom);
434 }
435 }
436 else
437 {
438 // return the attachment without any transcoding
439 context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_Dicom);
440 }
421 } 441 }
422 442
423 443
424 static void ExportInstanceFile(RestApiPostCall& call) 444 static void ExportInstanceFile(RestApiPostCall& call)
425 { 445 {