Module: storage-base-common

This module contains functions and definitions for the base storage module functions that are shared across all platforms.

Source:

Members

(static, constant) CREATION_STATUS :object

These static strings describe object creation. If an object did not exist yet - for versioned objects that includes any previous versions based on the ID-object - the status is "new". If an object that is to be created already exists (which is recognized because the names of all files are based on the SHA256 crypto hash of its contents) the status is "exists". For versioned objects this means the exact object already exists, not just a previous version (base don ID-object). The last state is used for versioned objects only. When a previous version of the object exists, based on the ID-object, but the exact version of the object does not, the object is created and added as a new version of the existing ID-object. Note: This is defined here and not in storage-unversioned-objects.js because then we would have to import that file here, but since we already do it the other way around it's easier to avoid a cyclic reference for such a minor thing, even though it works. Always use the names (keys) on this structure, never use the values themselves!

Type:
  • object
Properties:
Name Type Description
NEW 'new'

There was not even a previous version of this object

EXISTS 'exists'

This exact object (identified by SHA-256) already exists

Source:

(static, constant) SET_ACCESS_MODE :object

String constants for SetAccessParam's mode parameter.

Type:
  • object
Properties:
Name Type Description
REPLACE 'replace'
ADD 'add'
Source:

(static, constant) STORAGE :object

String constants for the storage types. Avoid having to repeat the string constant

Type:
  • object
Properties:
Name Type Description
"objects" OBJECTS
"private" PRIVATE
Source:

Methods

(static) createTempFileName() → {string}

Temporary filenames are needed for files we receive as streams, for example BLOBs received during Chum exchange. We won't know the SHA-256 normally used as filename until we received it completely.

NOTE: This function cannot be replaced by system/crypto-helpers createRandomString. We need this to be a synchronous function, or we would have to return SimpleWriteStream API objects asynchronously (undesirable because illogical).

Source:
Returns:

A randomly created temporary filename

Type: string