I use the Sardine WebDAV library and a Nextcloud server to achieve this.
Here's a sample Groovy script, to upload the content of a Bonita Document object to a Nextcloud server:
import com.github.sardine.*
// a short function to modify URLEncoder.encode's output to make filename spaces %20 instead of +
String encodeURL(String url) {
String u = URLEncoder.encode(url,"UTF-8").replace("+", "%20")
return u
}
String webpath = "https://your.nextcloud.server/remote.php/dav/files/(...)"
Sardine dav = SardineFactory.begin(webdavUser, webdavPassword)
dav.enablePreemptiveAuthentication("your.nextcloud.server")
// you'll want to things like verify or create the path to the upload point if necessary
if (!dav.exists(webpath)) {
dav.createDirectory(webpath))
}
Document doc = yourBonitaDocument
// store the document data in a byte object
byte[] docData = apiAccessor.getProcessAPI().getDocumentContent(doc.contentStorageId)
// Now upload the file to webpath
// (you'll want a try/catch routine here to handle failures, I've left it out for simplicity)
dav.put(encodeURL(webpath + "/" + doc.contentFileName), docData) // (or of course any another filename if you wish)
This sample depends on the Sardine library so you'll need to add it to your project (Overview > Extensions > Add a custom extension > Other, fill out the Maven details as per the link), and include it as a Java dependency in your process configuration (Configure > Production > Java dependencies > tick "sardine-5.xx.jar").
See also my answer (awnz) in the Bonitasoft forum here.