[FAQ]: Importing files to Filesystem using REST API

You can use the REST API to PUT individual files into the repository. For example:

PUT /elx/do/eno/dc/content/User/admin/sample.txt

will write into /User/admin/sample.txt

To import multiple files, like in the Designer, the REST API URL is

POST /elx/do/eno/dc/tool/upload?path=User/admin

and the body of the request is the set of files in .tgz format (just the same as the Designer)

You can also use a zip file as the request body:

POST /elx/do/eno/dc/tool/upload?path=User/admin&archival-format=zip

Note that for the REST API you need to pass appropriate authentication credentials with your request which match the access rights of the files you are attempting to manipulate. How these credentials are added to the REST API depends on which programming language and library you are using. For example with one Java library we can use:

HttpClient client = new HttpClient();

Credentials defaultCreds = new UsernamePasswordCredentials(“admin”,“sa”);

client.getState().setCredentials(new AuthScope(host,port,AuthScope.ANY_REALM), defaultCreds);

HttpClientParams params = client.getParams();

params.setCredentialCharset(CredentialCharset);

params.setAuthenticationPreemptive(true);

Refer to the following code samples for reference: RESTAPI_samples.zip (2.1 KB)