# new BlobStoreCustom (storeConfig:  Object, appInstance:  ServerApp, sessionInstance:  UBSession, optionsopt:  object)

Arguments:

Members

# accessAudit : boolean instance

Enable access audit for external requests for this BLOB store class

# App : ServerApp instance

# blacklistExtensionsSet : Set.<string> instance

Set of prohibited extensions (Example: '.jpg', '.png')

# checkForMaliciousPDF : boolean instance

Enable validation what uploaded PDF files do not contain JavaScript code

# config instance

Store parameters as defined in ubConfig

# historyDepth : number instance

How many previous revision is stored

# name instance

Name of store (from app config)

# Session : UBSession instance

# tempFolder : string instance

Path to temp folder

# whileListExtensionSet : Set.<string> instance

Set of allowed extensions (Example: '.jpg', '.png'). If null - any extension is allowed.

Methods

# validateFileExtension (ext:  string) static

Validate a file extension does not contain control characters (for example a line break) and path separators. An extension is taken from a file name passed by the client and becomes a part of a persisted file name, which is used in file system operations and in HTTP response headers

Arguments:

# validateFileName (fn:  string) static

validate file name contains only alphanumeric characters, -, _, . and space and not contains ..

Arguments:

# doArchive (attribute:  UBEntityAttribute, ID:  number, blobInfo:  BlobStoreItem) → BlobStoreItem instance

Do something with BLOB content during archiving. For example - move to slow drive etc. Default implementation do nothing.

Arguments:

# doDeletion (attribute:  UBEntityAttribute, ID:  number, blobInfo:  BlobStoreItem) instance

Delete persisted BLOB content

Arguments:

# extensionAllowed (ext:  string) → boolean instance

Check file extension allowed by store whileList and not prohibited dy store blackList

Arguments:

# fillResponse (requestParams:  BlobStoreRequest, blobInfo:  BlobStoreItem, req:  THTTPRequest, resp:  THTTPResponse, preventChangeRespOnErroropt:  boolean) → boolean instance

Fill HTTP response for getDocument request. Sets resp to 404 status if content not found.

Arguments:

# getContent (request:  BlobStoreRequest, blobInfo:  BlobStoreItem, optionsopt:  object) → string | UBMail.TubSendMailAttachKind.Buffer | ArrayBuffer | null instance

Retrieve BLOB content from blob store.

Arguments:

# getContentFilePath (request:  BlobStoreRequest, blobInfo:  BlobStoreItem) → string instance

Returns full path to the file with BLOB content

Arguments:

# getMimeType (fileNameOrExt:  string, isExtensionopt:  boolean) → string instance

Get mime type for passed file name or file extension. Recognize well known extensions missed in mime-db@1.52

Arguments:
  • fileNameOrExt: string
  • isExtension = false: boolean

    is first parameter a file extension (.pdf for example)

# getSecurityHeaders (ct:  string) → string instance

HTTP response headers which protect the application origin from content of the store. Content is uploaded by users and is served from the application origin, so:

  • X-Content-Type-Options: nosniff - a browser must not guess a content type
  • Content-Security-Policy: sandbox for HTML, SVG and XML - a browser shows such content, but does not run scripts in it and does not give it access to the application origin. Not added for other types: a browser PDF viewer does not work in a sandbox

When a reverse proxy sends files, it must add these headers itself: see BLOB stores locations in the config generated by ubcli generateNginxCfg

Return:

Headers, each one prepended by \r\n

Arguments:

# getTempFileName (request:  BlobStoreRequest) → string instance

Get path to temporary file and it's name

Arguments:

# persist (attribute:  UBEntityAttribute, ID:  number, dirtyItem:  BlobStoreItem, newRevision:  number) → BlobStoreItem | null instance

Move content defined by dirtyItem from temporary to permanent store. Return a new attribute content which describe a place of BLOB in permanent store

Arguments:

# saveContentToTempStore (request:  BlobStoreRequest, attribute:  UBEntityAttribute, content:  ArrayBuffer | THTTPRequest, optionsopt:  object) → BlobStoreItem instance

Save file content to temporary store with chunked upload support

Arguments:

# throwIfMaliciousPdf (filePath:  string, ct:  string) instance

If checkForMaliciousPDF is enabled for the store and ct is PDF - verify the file does not contain JavaScript. A file with JavaScript is deleted and an error is thrown.

A store must call this method before persisting content, using the content type the content is persisted with

Arguments: