Sometimes using the upload applet or other GUI-based tools to get your data into XNAT is not particularly practical. This article describes how to upload a zipped DICOM session directly to XNAT from the bash command line.
You must have a command-line HTTP client tool, such as curl or XnatDataClient, available for this to work.
To upload a Zip file to XNAT, you can POST the file to the /data/services/import REST endpoint, with the upload file specified using the image_archive query variable and multi-part form data encoding. The basic form of this command using curl would be:
This makes it pretty easy to do a bulk import. For example, suppose you want to upload all Zip files in a particular folder using this curl command. The following sample script takes the site URL, destination project ID, username and password, and the folder containing the files. The results of each transfer operation are written into a log file named according to the uploaded Zip file, with the log extension added on.
There are lots of different ways to get information out of curl to get better insight into what happened during the transfer operation. The sample above just returns the resulting HTTP status code.