Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Note

User resources are configured to be stored in the root cache space, defined by default as /data/home/xnat/cache. Cache spaces are not considered to be reliable long-term storage; many XNAT administrators set up cron jobs to clear this space.


Tip

A CSRF Token may be required for all PUT, POST and DELETE calls, depending on your Admin UI setting.

...

Tip

The following URI prefixes are interchangeable:

  • /data
  • /data/archive
  • /REST


Get All User Cache Resources

Returns all resource directories for the currently logged-in user. User resources are stored in the file system at CACHE_HOME/users/USERID/resources

...

Code Block
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<body>
<table class="x_rs_t" cellpadding="0" cellspacing="0">
    <thead class="x_rs_thead">
        <tr class="x_rs_tr_head">
            <th>Resource</th><th>URI</th>
        </tr>
    </thead>
    <tbody id="dataRows">
        <tr class="x_rs_tr_data odd">
            <td>uploads</td>
            <td><a href='/data/user/cache/resources/uploads'>/data/user/cache/resources/uploads</a></td>
        </tr>
    </tbody>
</table>
</body>
</html>


Create A User Cache Resource Folder

This creates a new folder in the XNAT root cache associated with the currently logged-in user account. The folder naming will use the user's numerical ID, i.e.: /ROOT_CACHE_SPACE/USERS/4/folder_name

Code Block
PUT - /data/user/cache/resources/{FOLDER}


Parameters:

{FOLDER}Path parameter – the resource ID
formatOptional querystring parameter
contentOptional querystring parameter
tagsOptional querystring parameter

Response:

200OK
412Precondition Failed (Occurs if the user is a guest account)


Get User Cache Resource File Listing

Code Block
GET - /data/user/cache/resources/{FOLDER}/files

Parameters:

{FOLDER}Path parameter – the resource ID
format
  • XML (default)
  • html
  • json
  • csv

Response:

Code Block
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<body>
    <table class="x_rs_t" cellpadding="0" cellspacing="0">
        <thead class="x_rs_thead">
            <tr class="x_rs_tr_head">
                <th>Name</th><th>Size</th><th>URI</th>
            </tr>
        </thead>
        <tbody id="dataRows">
            <tr class="x_rs_tr_data odd">
                <td>test.txt</td><td>4</td><td><a href='/xnat/data/user/cache/resources/junk/files/test.txt'>/data/user/cache/resources/junk/files/test.txt</a></td>
            </tr>
        </tbody>
    </table>
</body>
</html>


Upload A File To A User Cache Resource

If you are submitting a file via an HTML form, the form must have "multipart/form-data" encoding.

Code Block
PUT - /data/user/cache/resources/{FOLDER}/files/{FILE}

Parameters:

{FOLDER}Path parameter – the resource ID
{FILE}Path parameter – the filename you wish to save your file as
fileForm data – the file you wish to upload

Response: None


Delete A File From A User Cache Resource

Code Block
DELETE - /data/user/cache/resources/{FOLDER}/files/{FILE}

Parameters:

{FOLDER}Path parameter – the resource ID
{FILE}Path parameter – the filename you wish to delete