FileSystemBlobStore

FileSystemBlobStore

Blob store implementation for storing content inside models public folders. Key conceptions:

  • relative path created in format modelName|relativePathFromModelDir to hide real file place from client
  • OS user temp folder used for store temporary content
  • delete operation is forbidden since models must be under version control

    Used in:

  • ubm_form for store form def & js inside /public/forms

  • ubm_diagrams for store diagram inside /public/erdiagrams
  • ubs_report for store report template inside /public/reports
  • e.t.c.

Constructor

new FileSystemBlobStore(storeConfig, appInstance, sessionInstance, storeConfig)

Arguments:
  1. storeConfig (Object)
  2. appInstance (App)
  3. sessionInstance (UBSession)
  4. storeConfig

Members

fullStorePath

Normalized path to the store root

Methods

doDeletion(attribute, ID, blobInfo)

Arguments:
  1. attribute (UBEntityAttribute)
  2. ID (Number)
  3. blobInfo (BlobStoreItem)

fillResponse(requestParams, blobInfo, req, resp)Boolean

Fill HTTP response for getDocument request
Arguments:
  1. requestParams (BlobStoreRequest)
  2. blobInfo (BlobStoreItem)  Document metadata. Not used for dirty requests
  3. req (THTTPRequest)
  4. resp (THTTPResponse)

genNewPlacement(attribute, dirtyItem, ID)Object protected

Calculate a relative path & file name for a new BLOB item. If new folder dose not exists - create it
Arguments:
  1. attribute (UBEntityAttribute)
  2. dirtyItem (BlobStoreItem)
  3. ID (Number)

getContent(request, blobInfo, optionsopt)String|ArrayBuffer

Retrieve BLOB content from blob store.
Arguments:
  1. request (BlobStoreRequest)
  2. blobInfo (BlobStoreItem)  JSON retrieved from a DB.
  3. [options] (Object)
    Properties
    1. [encoding] (String|Null)  Default to 'bin'. Possible values: 'bin'|'ascii'|'utf-8' If undefined UB will send query to entity anf get it from DB. At last one parameter {store: storeName} should be defined to prevent loading actual JSON from DB

getPermanentFileName(blobItem, requestopt)String protected

For file based store:

  • store.path + relativePath + fileName
Arguments:
  1. blobItem (BlobStoreItem)
  2. [request] (BlobStoreRequest)  Optional request to get a revision

persist(attribute, ID, dirtyItem, newRevision)BlobStoreItem|null

Move content defined by dirtyItem from temporary to permanent store. TIPS: in v0 (UB<5) if file updated then implementation takes a store from old item. This raise a problem - old store may be in archive state (readonly) So in UB5 we change implementation to use a store defined in the attribute for new items

Return a new attribute content which describe a place of BLOB in permanent store

Arguments:
  1. attribute (UBEntityAttribute)
  2. ID (Number)
  3. dirtyItem (BlobStoreItem)
  4. newRevision (number)

saveContentToTempStore(request, attribute, content)BlobStoreItem

Arguments:
  1. request (BlobStoreRequest)  Request params
  2. attribute (UBEntityAttribute)
  3. content (ArrayBuffer)