Skip to main content
Skip table of contents

User Resources API

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.

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

Get All User Cache Resources

Returns all resource directories for the currently logged-in user.

CODE
GET - /data/user/cache/resources/

Parameters:

format

  • XML (default)

  • JSON

  • HTML

  • CSV

Response:

CODE
<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
PUT - /data/user/cache/resources/{FOLDER}

Parameters:

{FOLDER}

Path parameter – the resource ID

format

Optional querystring parameter

content

Optional querystring parameter

tags

Optional querystring parameter

Response:

200

OK

412

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

Get User Cache Resource File Listing

CODE
GET - /data/user/cache/resources/{FOLDER}/files

Parameters:

{FOLDER}

Path parameter – the resource ID

format

  • XML (default)

  • html

  • json

  • csv

Response:

CODE
<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
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

file

Form data – the file you wish to upload

Response: None


Delete A File From A User Cache Resource

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

Parameters:

{FOLDER}

Path parameter – the resource ID

{FILE}

Path parameter – the filename you wish to delete

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.