zip download error

Hello,

Has anyone had trouble downloading zip files from the Orthanc Explorer? When I try to download the zip file it takes a few minutes and then says it has successfully completed but when I view the zip file its too small to contain any files or says “invalid zip”. I’m wondering if its because we have a lot of large multi-band sequences in our protocol?

I have had it successfully work twice. I have not done anything differently when it doesn’t work and the scan files are about the same size.

Thank you!

Alison

Hello,

If your DICOM study is so large that it takes a few minutes to generate a ZIP file, this leads to a timeout in the HTTP protocol.

You should use the asynchronous mode to generate the ZIP file (which is not implemented in the Orthanc Explorer):
http://book.orthanc-server.com/users/advanced-rest.html#synchronous-vs-asynchronous-calls
http://book.orthanc-server.com/faq/improving-interface.html

Here is a sample interactive session of such an asynchronous operation:

$ curl http://localhost:8042/studies/8fb41d30-e6057100-f693d86f-b6819d72-4fc1a9b9/archive -X POST -d ‘{“Synchronous”:false}’
{
“ID” : “24c22a0f-0ec1-468e-a4e8-73ac2ec8a741”,
“Path” : “/jobs/24c22a0f-0ec1-468e-a4e8-73ac2ec8a741
}
$ curl http://localhost:8042/jobs/24c22a0f-0ec1-468e-a4e8-73ac2ec8a741
{
“CompletionTime” : “20190508T082249.985684”,
“Content” : {
“Description” : “REST API”,
“InstancesCount” : 46,
“UncompressedSizeMB” : 5
},
“CreationTime” : “20190508T082249.727206”,
“EffectiveRuntime” : 0.255,
“ErrorCode” : 0,
“ErrorDescription” : “Success”,
“ID” : “24c22a0f-0ec1-468e-a4e8-73ac2ec8a741”,
“Priority” : 0,
“Progress” : 100,
“State” : “Success”,
“Timestamp” : “20190508T082257.001143”,
“Type” : “Archive”
}
$ curl http://localhost:8042/jobs/24c22a0f-0ec1-468e-a4e8-73ac2ec8a741/**archive** > /tmp/archive.zip

HTH,

Sébastien-

Hi Sebastien,

Thank you for your response. We’re having some trouble with this:

The first call:
$ curl http://localhost:8042/studies/8fb41d30-e6057100-f693d86f-b6819d72-4fc1a9b9/archive -X POST -d ‘{“Synchronous”:false}’

contains what I assume is the uuid (e.g., http://localhost:8042/app/explorer.html#study?uuid=8fb41d30-e6057100-f693d86f-b6819d72-4fc1a9b9 ) from the orthanc explorer, but I really have no clue as that string (8fb41…) disappears in the subsequent calls like:

$ curl http://localhost:8042/jobs/24c22a0f-0ec1-468e-a4e8-73ac2ec8a741

So, I don’t know where we would find that 8fb string, and when I try using the id (or uuid) from orthanc explorer, none of the steps work. I’m also not sure I can make asynchronous calls as that syntax generates errors like:

Invoke-WebRequest : Parameter cannot be processed because the parameter name ‘d’ is ambiguous. Possibl

include: -DisableKeepAlive -Debug.

At line:1 char:97

  • … rchive -X POST -d

  • ~~

  • CategoryInfo : InvalidArgument: (:slight_smile: [Invoke-WebRequest], ParameterBindingException

  • FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

I have attached a screenshot as well.

Thank you!

OrthancCommandLine.jpg

The “8fb…” ID is indeed the Orthanc identifier of a DICOM study of mine:
http://book.orthanc-server.com/faq/orthanc-ids.html

The “24c…” ID is the random identifier of the asynchronous job that consists in creating an archive from the study:
http://book.orthanc-server.com/users/advanced-rest.html#monitoring-jobs

As an unique, random identifier, the “24c…” will change for each call to the asynchronous API.

Thanks for this information. Unfortunately, I cannot get any of the calls with various combinations of POST syntax I’ve tried to work. Are there any examples of asynchronous calls on a windows installation of orthanc? If none of the syntax works, does this mean I don’t have the rest API installed properly? For example -X POST generates syntax errors, but -Method POST seems to be acceptable syntax, it just still fails to recognize/understand the ‘{“synchronous”:false}’ part.

For example, if I just run curl http://localhost:8042/jobs

I can guarantee you that the calls from my previous post work properly on GNU/Linux platforms with bash:
https://groups.google.com/d/msg/orthanc-users/IEVJdR-z-4Y/EUawQoowBAAJ

This is a Windows-specific issue related to escaping characters in shells, for which I personally can’t provide support:
https://en.wikipedia.org/wiki/Escape_character#Windows_Command_Prompt

Hello

When you type curl, it actually calls Invoke-WebRequest, that is not compatible with curl in terms of flags (The Powershell team admitted that hijacking the curl alias was a very bad idea)

To sole this, you can either choose to install and use curl or fix the Invoke-WebRequest flags.

  • In order to use curl from Powershell, use curl.exe instead of curl : this will ensure the actual curl is used.

  • If you prefer to use the Windows native tools, you can find an example of Invoke-WebRequest in the Orthanc book :

http://book.orthanc-server.com/users/advanced-rest.html#pdf

Hope this helps!

Thanks for this info Benjamin.

I can now run:

PS C:\Users\VHASFCROACHB> Invoke-WebRequest -Uri http://localhost:8042/studies/608332e1-535e1e15-f97f323f-4560532e-be794
7f5/archive -Method POST -Body ‘{“Synchronous”:false}’

and get:

StatusCode : 200
StatusDescription : OK
Content : {
“ID” : “768698d3-fc25-4f40-a5b8-7bf3714bcb37”,
“Path” : “/jobs/768698d3-fc25-4f40-a5b8-7bf3714bcb37”
}

RawContent : HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 111
Content-Type: application/json; charset=utf-8

{
“ID” : “768698d3-fc25-4f40-a5b8-7bf3714bcb37”,
“Path” : "/jobs/768698d3-fc25-4f40…
Forms : {}
Headers : {[Connection, keep-alive], [Content-Length, 111], [Content-Type, application/json; charset=utf-8]}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : System.__ComObject
RawContentLength : 111

then I can run:
PS C:\Users\VHASFCROACHB> Invoke-WebRequest -Uri http://localhost:8042/jobs/768698d3-fc25-4f40-a5b8-7bf3714bcb37

and get:

StatusCode : 200
StatusDescription : OK
Content : {
“Content” : {
“Description” : “REST API”,
“InstancesCount” : 9533,
“UncompressedSizeMB” : 2498
},
“CreationTime” : “20190520T204028.318424”,
“EffectiveRuntime” : 142.75…
RawContent : HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 504
Content-Type: application/json; charset=utf-8

{
“Content” : {
“Description” : “REST API”,
“InstancesCount” : 9533,

Forms : {}
Headers : {[Connection, keep-alive], [Content-Length, 504], [Content-Type, application/json; charset=utf-8]}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : System.__ComObject
RawContentLength : 504

If I just plug that url into a browser, I can keep getting the full json information, which eventually lists:

{
“CompletionTime” : “20190520T205821.664025”,
“Content” : {
“Description” : “REST API”,
“InstancesCount” : 9533,
“UncompressedSizeMB” : 2498
},
“CreationTime” : “20190520T204028.318424”,
“EffectiveRuntime” : 1028.9929999999999,
“ErrorCode” : 0,
“ErrorDescription” : “Success”,
“ID” : “768698d3-fc25-4f40-a5b8-7bf3714bcb37”,
“Priority” : 0,
“Progress” : 100,
“State” : “Success”,
“Timestamp” : “20190520T214238.507178”,
“Type” : “Archive”
}

then I try:

PS C:\Users\VHASFCROACHB> Invoke-WebRequest -Uri http://localhost:8042/jobs/768698d3-fc25-4f40-a5b8-7bf3714bcb37/archive > D:.…\zipTest.zip

and this did not work - the zip file is corrupted, even though I saw a long-running dialogue in the power shell indicating that lots of bytes were being read. Have I made an obvious syntax error at this last step or in some prior step?

thanks,
Brian

Hello Brian

Redirecting the binary output of Powershell commands using the > operator is unfortunately often unreliable (see https://brianreiter.org/2010/01/29/powershells-object-pipeline-corrupts-piped-binary-data/). I think this was not part of their design goals to treat raw bytes as pipe-able data. This is often a problem when mixing unix-style command line programs with Powershell.

Could you please give it a try using the Invoke-WebRequest -OutFile parameter ?

Let me know how this goes!

It worked!!! Thank you so much!

specifically, this:

PS C:\Users\VHASFCROACHB> Invoke-WebRequest -Uri http://localhost:8042/jobs/768698d3-fc25-4f40-a5b8-7bf3714bcb37/archive
-OutFile ‘D:.…\zipTestMay202019.zip’

The -OutFile argument must be a ‘characterString’ path to the destination OutFile, so single quote were required to make it work. If you run it this way:

PS C:\Users\VHASFCROACHB> Invoke-WebRequest -Uri http://localhost:8042/jobs/768698d3-fc25-4f40-a5b8-7bf3714bcb37/archive
-OutFile D:.…\zipTestMay202019.zip

It seems like it’s working, generates a file, but the file is not the actual archive.

Hi Brian

Thanks for the feedback!

I am puzzled as to why the single quotes are required in this case.

Were there maybe spaces or backticks (`) in the D:.… file path? Being given what happens without quotes, it seems to be something else but my imagination fails on me on that one!

Cheers.