WebDav (UB Enterprise Edition) #

Expose BLOB stores / file system to be opened / edit using WebDav protocol

It's recommended to use a @ub-e/webdav-model - it register a WebDav endpoint and BlobStore based WebDav provider based on configuration from ubConfig.customSettings.webdav

  • install package:
npm i @ub-e/webdav-model
  • add @ub-e/webdav-model to application domain in the ubConfig.json:
{
  "application": {
    "domain": {
      "models": [
        {"path": "./node_modules/@ub-e/webdav-model"}
      ]
    }
  }
}
  • add entities (mandatory) what contains BLOB attribute what should be accessible using WebDav
{
  "application": {
    "customSettings": {
      "webdav": {
        "entities": [{"name": "tst_document"}, {"name": "tst_clob"}]
      }
    }
  }
}

The best way is to add a section with entities to the model partial config - in this case, if several model defines their set of entities, they will be merged from all partials into one array.

  • optionally customize a parameters (strongly recommended to keep defaults) By default model adds the following ubConfig-partial:
{
  "application": {
    "customSettings": {
      "webdav": {
        "enabled": %UB_USE_WEBDAV||true%,
        "endpointName": "%UB_WEBDAV_ENDPOINT_NAME||folders%",
        "providerName": "%UB_WEBDAV_PROVIDER_NAME||dav%",
        "entities": []
      }
    }
  }
}

On the client side @unitybase/adminui-vue exports a webDav namespace what contains client-side functions. Example:

const adminuiVue = require('@unitybase/adminui-vue')
if (
  adminuiVue.webDav.isEntitySupportWebDav(this.entityName) &&
  adminuiVue.webDav.canBeOpenedInApp(this.fileName)
) {
  adminuiVue.webDav.openInApp({
    entity: this.entityName,
    attribute: this.attributeName,
    ID: this.fileId
  }, this.fileName)
}

Low-level #

On the low level custom WebDav endpoint can be registered using @ub-e/web-dav package, what implements a WebDav protocol

Add @ub-e/web-dav module to your app:

npm i --save @ub-e/web-dav

And use it in your model main file with appropriate provider:

const WebDav = require('@ub-e/web-dav')
const WebDavBlobStoreProvider = require('@ub-e/web-dav/providers/webDavBlobStoreProvider')
const WebDavFsProvider = require('@ub-e/web-dav/providers/webDavFileSystemProvider')
WebDav.registerEndpoint('folders')
  .addProvider(new WebDavBlobStoreProvider({
    name: 'doc',
    entities: ['tst_document']
  }))
  .addProvider(new WebDavFsProvider({
    name: 'fs',
    path: process.configPath
  }))

WebDavFsProvider expose a folder process.coonfigPath as WebDav root (do not do such on production!!)

To access files use URL:

  • on Windows \\localhost@8881\folders\fs in Explorer
  • on Linux dav://localhost:8881/folders/fs into Files -> Other locations

WebDavBlobStoreProvider expose all BLOB attributes for tst_document entity. Content can be opened directly by Word, Excel, Notepad etc. using URL \\localhost@8881\folders\doc\tst_document\fileStoreSimple\332468137394197\0.docx, where:

  • tst_document - entity code
  • fileStoreSimple - BLOB attribute code
  • 332468137394197 - instance ID
  • 0 - reserved for version. Current implementation support only 0
  • docx - file extension

Editable content #

  • WebDavBlobStoreProvider allow to save BLOB to server in case entity support locking (softLock mixin is added to entity)
  • WebDavFsProvider allow to save files back to server for ANY authorised user

Authentication #

Current implementation support ONLY Negotiate authentication, so Negotiate must be present in the security.authenticationMethods of the application config.

Implementing your provider #

Every provider should be inherited from CustomWebDavProvider and implement all abstract method of base class