0
votes

I'm using exist-db over docker container. Installing Java over Ubuntu and install the eXist installation headless jar, also adding data Volume (Azure file), that store all the physically files and the db data file.

I need to upload automatically files to the exist-db, after I generate new file and saving it to the volume drive, (using C#).

According to eXist documentation there are several methods to upload , but non of them works for me.

  1. Dashboard or eXide - not relevant - it supposed to be GUI applications.
  2. Java Admin Client - not working because have no GUI -> I'm getting this failure: 'No X11 DISPLAY variable was set, but this program performed an operation which requires it...'
  3. Over REST or WebDAV via web client (using browser or by code), I can run xQuery for queries, but for storing new file? how?

So, the solution I found is to write xQuery file, using xmldb:store function.

Set the new file name and location(in the volume) and run it by WebDAV or REST.

But I feel that there is a simpler solution...

Anyone can help?

BTW, this it the xmldb:store Xquery file:

xquery version "3.1";

declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
import module namespace xmldb="http://exist-db.org/xquery/xmldb";

declare function local:upload() {

    let $filename := request:get-uploaded-file-name('file')

    let $log-in := xmldb:login("/db", "Admin", "admin")
    let $file := 'file:////usr/new_file_location.xml'
    let $record := doc($file)
    let $store := xmldb:store("/db/akn", "new_file_name.xml",  $record )

    return
<results>
   <message>File {$file} has been stored.</message>
</results>

};

local:upload()
1

1 Answers

1
votes

When starting eXist as described in the eXist Docker documentation - with it listening on port 8080 - you can access all of eXist's standard endpoints:

  • http://localhost:8080/exist/webdav/db for WebDAV
  • http://localhost:8080/exist/rest/db for REST
  • http://localhost:8080/exist/xmlrpc/db for XML-RPC
  • http://localhost:8080/exist/apps for apps installed in /db/apps.

Of course if you've configured Docker's eXist to listen on a different port, just switch the port.

Thus, to upload files to a Dockerized eXist programmatically, the methods outlined in the documentation article you referenced, Uploading files, should all work: WebDAV, client.sh, Ant, or even curl. For WebDAV, if you haven't configured users and passwords, you'd just connect with the URL http://localhost:8080/exist/webdav/db, username "admin", and a blank password. For Ant, see the Ant tasks documentation. For curl, you would perform an HTTP PUT request to the REST interface:

curl -s -f -H 'Content-Type: application/xml' \
     -T <filename> \
     --user <user>:<password> \
     "http://localhost:8080/exist/rest/db/apps/<collection>/<filename>"