Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 4804:ae643f664628
new option returnUnsupportedImage for /preview & /rendered routes
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 28 Oct 2021 13:05:56 +0200 |
parents | 3b78ba359db3 |
children | 7afbb54bd028 |
comparison
equal
deleted
inserted
replaced
4803:1eca4378d761 | 4804:ae643f664628 |
---|---|
753 | 753 |
754 call.GetDocumentation() | 754 call.GetDocumentation() |
755 .SetTag("Instances") | 755 .SetTag("Instances") |
756 .SetUriArgument("id", "Orthanc identifier of the DICOM instance of interest") | 756 .SetUriArgument("id", "Orthanc identifier of the DICOM instance of interest") |
757 .SetHttpGetArgument("quality", RestApiCallDocumentation::Type_Number, "Quality for JPEG images (between 1 and 100, defaults to 90)", false) | 757 .SetHttpGetArgument("quality", RestApiCallDocumentation::Type_Number, "Quality for JPEG images (between 1 and 100, defaults to 90)", false) |
758 .SetHttpGetArgument("returnUnsupportedImage", RestApiCallDocumentation::Type_Boolean, "Returns an unsupported.png placeholder image if unable to provide the image instead of returning a 415 HTTP error (defaults to false)", false) | |
758 .SetHttpHeader("Accept", "Format of the resulting image. Can be `image/png` (default), `image/jpeg` or `image/x-portable-arbitrarymap`") | 759 .SetHttpHeader("Accept", "Format of the resulting image. Can be `image/png` (default), `image/jpeg` or `image/x-portable-arbitrarymap`") |
759 .AddAnswerType(MimeType_Png, "PNG image") | 760 .AddAnswerType(MimeType_Png, "PNG image") |
760 .AddAnswerType(MimeType_Jpeg, "JPEG image") | 761 .AddAnswerType(MimeType_Jpeg, "JPEG image") |
761 .AddAnswerType(MimeType_Pam, "PAM image (Portable Arbitrary Map)") | 762 .AddAnswerType(MimeType_Pam, "PAM image (Portable Arbitrary Map)") |
762 .SetDescription(description); | 763 .SetDescription(description); |
815 // The frame number is out of the range for this DICOM | 816 // The frame number is out of the range for this DICOM |
816 // instance, the resource is not existent | 817 // instance, the resource is not existent |
817 } | 818 } |
818 else | 819 else |
819 { | 820 { |
820 std::string root = ""; | 821 if (call.HasArgument("returnUnsupportedImage")) |
821 for (size_t i = 1; i < call.GetFullUri().size(); i++) | |
822 { | 822 { |
823 root += "../"; | 823 std::string root = ""; |
824 for (size_t i = 1; i < call.GetFullUri().size(); i++) | |
825 { | |
826 root += "../"; | |
827 } | |
828 | |
829 call.GetOutput().Redirect(root + "app/images/unsupported.png"); | |
824 } | 830 } |
825 | 831 else |
826 call.GetOutput().Redirect(root + "app/images/unsupported.png"); | 832 { |
833 call.GetOutput().SignalError(HttpStatus_415_UnsupportedMediaType); | |
834 } | |
827 } | 835 } |
828 return; | 836 return; |
829 } | 837 } |
830 | 838 |
831 } | 839 } |