Managing files
The /files resource accesses and controls files and file permissions. A file is stored on a volume, and contains data and visualizations for the iHub system. A unique file ID number assigned by the iHub system identifies each file. Files include report designs, raw and formatted documents, and BIRT data objects. The /files resource can also upload and download files to and from a volume.
The following sections provide an example of using each files resource as a curl command.
GET files
This example requests the list of files that are not directories in the root directory of the volume:
GET /ihub/v1/files HTTP/1.1
Host: myserver.mycompanyname.com:5000
AuthId: <authId>
This example requests the list of files that have the extension .rptdocument within the folder with the folder ID 340000000100:
GET /ihub/v1/files?folderId=340000000100&search=*.rptdocument HTTP/1.1
Host: myserver.mycompanyname.com:5000
AuthId: <authId>
This curl example requests the list of files within the folder that have the extension .rptdocument within the folder ID 340000000100 in the default volume:
curl -i http://%RESTHost%:5000/ihub/v1/files?folderId=340000000100 ‑G ‑H "AuthId:%RESTAuthId%" ‑d search=*.rptdocument
GET files/{fileId}
This example requests the details for the file with the file ID 640000000100:
GET /ihub/v1/files/640000000100 HTTP/1.1
Host: myserver.mycompanyname.com:5000
AuthId: <authId>
This curl example requests the details of the file with the file ID 640000000100 in the default volume:
curl -i http://%RESTHost%:5000/ihub/v1/files/640000000100 ‑H "AuthId:%RESTAuthId%"
DELETE files/{fileId}
This example deletes the file with the file ID 860000000100:
DELETE /ihub/v1/files/860000000100 HTTP/1.1
Host: myserver.mycompanyname.com:5000
Content-Type: application/json
AuthId: <authId>
This curl DELETE request example deletes the file with the file ID 860000000100 from the default volume:
curl -i http://%RESTHost%:5000/ihub/v1/files/860000000100 ‑X DELETE ‑H "AuthId:%RESTAuthId%"
GET files/{fileId}/privileges
This example returns the privileges assigned to file ID 640000000100:
GET /ihub/v1/files/640000000100/privileges HTTP/1.1
Host: myserver.mycompanyname.com:5000
AuthId: <authId>
This curl example requests the ACL for the file with the file ID 640000000100 in the default volume:
curl -i http://%RESTHost%:5000/ihub/v1/files/640000000100 ‑H "AuthId:%RESTAuthId%"
GET files/{fileId}/download
This example downloads the content of the file with the file ID 640000000100 without base-64 encoding:
GET /ihub/v1/files/640000000100/download?base64Encode=false HTTP
/1.1
Host: myserver.mycompanyname.com:5000
AuthId: <authId>
This curl example downloads the content of the file with the file ID 640000000100 from the default volume without base-64 encoding:
curl -i http://%RESTHost%:5000/ihub/v1/files/640000000100/download ‑G ‑H "AuthId:%RESTAuthId%" ‑d base64Encode=false
POST files/{file}/upload
The following HTTP request uploads the file Sales-Reps.rptdesign to the /Sales folder and replaces the existing file:
POST /ihub/v1/files/Sales-Reps.rptdesign/upload HTTP/1.1
Host: myserver.mycompanyname.com:5000
 
AuthId: <authId>
 
Content-Type: multipart/form-data; boundary=----------------------------58401aa09219
 
------------------------------58401aa09219
Content-Disposition: form-data; name="name"
 
/Sales/Sales-Reps.rptdesign
------------------------------58401aa09219
Content-Disposition: form-data; name="file";
filename="Sales-Reps.rptdesign"
Content-Type: application/octet-stream
 
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 4.4.0.v20140819-0300 Build &lt;4.2.3.v20140819-0300></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="layoutPreference">auto layout</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<list-property name="libraries">
<structure>
<property name="fileName">/ThemesReportItems3.rptlibrary</property>
<property name="namespace">ThemesReportItems3</property>
</structure>
</list-property>
...
</body>
</report>
 
------------------------------58401aa09219
Content-Disposition: form-data; name="replace"
 
true
------------------------------58401aa09219--
This curl POST request example uploads the file Sales-Reps.rptdesign to the
/Sales folder in the default volume and replaces the existing file:
curl -i http://%RESTHost%:5000/ihub/v1/files/Crosstab%20Sample%20Revenue.rptdesign/upload ‑X POST ‑H "AuthId:%RESTAuthId%" ‑F name=/Sales/Sales‑Reps.rptdesign ‑F file=@Sales‑Reps.rptdesign
PUT files/{fileId}
The following HTTPS request changes the name of the file with file ID 640000000100 to /Public/Application1/Shipped Orders.rptdesign:
PUT /ihub/v1/folders/640000000100 HTTP/1.1
Host: myserver.mycompanyname.com:5010
Content-Type: application/x-www-form-urlencoded
AuthId: <authId>
 
newName=/Public/Application1/Shipped%20Orders.rptdesign
This curl PUT request example changes the name and path of the file with the file ID 640000000100 to /Public/Application1/Shipped Orders.rptdesign in the default volume:
curl -i http://%RESTHost%:5010/ihub/v1/files/640000000100 ‑X PUT ‑H "AuthId:%RESTAuthId%" ‑d newName=/Public/Application1
/Shipped%20Orders.rptdesign
POST files/{fileId}/privileges
The following HTTP request changes the privileges for the file with file ID 640000000100:
POST /ihub/v1/files/6400000000100/privileges HTTP/1.1
Host: myserver.mycompanyname.com:5000
Content-Type: application/json; charset=utf-8
AuthId: <authId>
 
{"Permission": [{"UserGroupName":"All", "AccessRight":"VS"}, {"UserName":"Maria Castillo", "AccessRight":"GRESVWD"}, {"UserGroupName":"Sales", "AccessRight":"VSEW"}]}
This curl POST request example changes the ACL of the file with the file ID 640000000100 to the ACL in the escaped JSON string:
curl -i http://%RESTHost%:5000/ihub/v1/files/640000000100/privileges ‑X POST ‑H "AuthId:%RESTAuthId%" ‑H "Content‑Type: application/json" ‑d "{\"Permission\":
[{\"UserGroupName\":\"All\", \"AccessRight\":\"VS\"},
{\"UserName\":\"Maria Castillo\", \"AccessRight\":\"GRESVWD\"},
{\"UserGroupName\":\"Sales\", \"AccessRight\":\"VSEW\"}]}"