# HG changeset patch # User Sebastien Jodogne # Date 1597676118 -7200 # Node ID 13bb9af3df26c92788a37d7ad64285874151bc6a # Parent 5abd8869514ffb9203b4ed2bf6b9b6abfdc41f55 Example: Asynchronous generation of an archive diff -r 5abd8869514f -r 13bb9af3df26 Sphinx/source/users/advanced-rest.rst --- a/Sphinx/source/users/advanced-rest.rst Mon Aug 17 14:58:38 2020 +0200 +++ b/Sphinx/source/users/advanced-rest.rst Mon Aug 17 16:55:18 2020 +0200 @@ -151,10 +151,55 @@ The related state machine is depicted in the `implementation notes `__. - +Example: Asynchronous generation of an archive +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. highlight:: bash + +Sucessful jobs are associated with a set of so-called "outputs" that +can be attached to the job. + +Here is a sample bash session to ask Orthanc to generate a ZIP +archive, then to download it locally:: + + $ curl http://localhost:8042/studies/27f7126f-4f66fb14-03f4081b-f9341db2-53925988/archive -d '{"Asynchronous":true}' + { + "ID" : "82cc02d1-03fe-41f9-be46-a308d16ea94a", + "Path" : "/jobs/82cc02d1-03fe-41f9-be46-a308d16ea94a" + } + $ curl http://localhost:8042/jobs/82cc02d1-03fe-41f9-be46-a308d16ea94a + { + "CompletionTime" : "20200817T144700.401777", + "Content" : { + "Description" : "REST API", + "InstancesCount" : 232, + "UncompressedSizeMB" : 64 + }, + "CreationTime" : "20200817T144658.011824", + "EffectiveRuntime" : 2.3879999999999999, + "ErrorCode" : 0, + "ErrorDescription" : "Success", + "ID" : "82cc02d1-03fe-41f9-be46-a308d16ea94a", + "Priority" : 0, + "Progress" : 100, + "State" : "Success", + "Timestamp" : "20200817T144705.770825", + "Type" : "Archive" + } + $ curl http://localhost:8042/jobs/82cc02d1-03fe-41f9-be46-a308d16ea94a/archive > a.zip + +Note how we retrieve the content of the archive by accessing the +``archive`` output of the job (check out the virtual method +``IJob::GetOutput()`` from the `source code +`__ +of Orthanc). + +As of Orthanc 1.7.2, only the creation of a ZIP or a DICOMDIR archive +produces such an "output". + + .. _pdf: Attaching PDF file as DICOM series