1.0.1 Updating File Resources¶
For an existing file resource, you can update its name, description or file contents in several ways.
The simplest way is to PUT a file descriptor containing the new file in base64 encoding. This new definition of the file resource overwrites the previous one.
Method |
URL |
||
PUT |
http://<host>:<port>/jasperserver[-pro]/rest_v2/resources/path/to/resource |
||
Content-Type |
Content |
||
application/repository.file+json application/repository.file+xml |
A well defined file resource descriptor, as described in 1.0.1.14, “File,” on page 1. The new contents of the file are base64 encoded in the |
||
Return Value on Success |
Typical Return Values on Failure |
||
201 Created – The request was successful and, for confirmation, the response contains the full descriptor of the resource that was just created. |
400 Bad Request – Mismatch between the content-type and the fields or syntax of the actual descriptor. |
||
The second method allows you to update a file resource by direct streaming. You can specify the Content-Description and Content-Disposition headers to update the resource description or name, respectively.
Method |
URL |
||
PUT |
http://<host>:<port>/jasperserver[-pro]/rest_v2/resources/path/to/resource |
||
Options |
|||
Content-Description: <file-description> - Becomes the description field of the created file resource Content-Disposition: attachment; filename=<filename> - Becomes the name of the file resource |
|||
Content-Type |
Content |
||
{MIME type} |
The MIME type from Table 1-1, “File Types and MIME Types,” on page 1 that corresponds to the desired file type. The body of the request then contains the binary data representation of that file format. |
||
Return Value on Success |
Typical Return Values on Failure |
||
201 Created – The request was successful and, for confirmation, the response contains the full descriptor of the resource that was just created. |
400 Bad Request – Mismatch between the content-type and the fields or syntax of the actual descriptor. |
||