Mercurial > hg > orthanc-book
diff Sphinx/source/users/advanced-rest.rst @ 297:64d1ddab8246
Improved PDF creation Pwsh snippet + added Dicom instance upload example with
Pwsh + added Windows docker script to generate book
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 20 Jan 2020 14:43:22 +0100 |
parents | 6cbcdb965ad3 |
children | c13431b26e55 |
line wrap: on
line diff
--- a/Sphinx/source/users/advanced-rest.rst Tue Jan 07 08:37:15 2020 +0100 +++ b/Sphinx/source/users/advanced-rest.rst Mon Jan 20 14:43:22 2020 +0100 @@ -164,9 +164,9 @@ They convert the ``HelloWorld2.pdf`` file to base64, then perform a ``POST`` request with JSON data containing the converted payload. -.. highlight:: bash +Using bash: -Using bash:: +.. code-block:: bash # create the json data, with the BASE64 data embedded in it (echo -n '{"Tags" : {"PatientName" : "Benjamino", "Modality" : "CT"},"Content" : "data:application/pdf;base64,'; base64 HelloWorld2.pdf; echo '"}') > /tmp/foo @@ -174,9 +174,10 @@ # upload it to Orthanc cat /tmp/foo | curl -H "Content-Type: application/json" -d @- http://localhost:8042/tools/create-dicom -.. highlight:: powershell -Using Powershell:: +Using powershell: + +.. code-block:: perl # create the BASE64 string data $fileInBase64 = $([Convert]::ToBase64String((gc -Path "HelloWorld2.pdf" -Encoding Byte))) @@ -184,8 +185,11 @@ # create the json data $params = @{Tags = @{PatientName = "Benjamino";Modality = "CT"};Content= "data:application/pdf;base64,$fileInBase64"} - # upload it to Orthanc and convert the result to json - $reply = Invoke-WebRequest -Uri http://localhost:8042/tools/create-dicom -Method POST -Body ($params|ConvertTo-Json) -ContentType "application/json" | ConvertFrom-Json + # disabling progress bar tremendously increases the Invoke-RestMethod call + $ProgressPreference = 'SilentlyContinue' + + # upload it to Orthanc + $reply = Invoke-RestMethod http://localhost:8042/tools/create-dicom -Method POST -Body ($params|ConvertTo-Json) -ContentType 'application/json' # display the result Write-Host "The instance can be retrieved in PDF at http://localhost:8042$($reply.Path)/pdf"