Class: StorageObject

StorageObject()

new StorageObject()

Represents a StorageObject instance
Do not call constructor directly.
Source:
See:

Members

(readonly) contentType :string

The most close contentType for this storage object based on it's extension. It's undefined if this storage object is a folder.
Type:
  • string
Source:

(readonly) isFolder :boolean

Is this storage object a folder?
Type:
  • boolean
Source:

(readonly) length :integer

The length/size in bytes of this storage object. 0 if it's a folder
Type:
  • integer
Source:

(readonly) name :string

The name of this storage object. In a filesystem storage, this is the name of a folder or a file
Type:
  • string
Source:

(readonly) timestamp :Date

The lastModified date of this storage object
Type:
  • Date
Source:

Methods

copy(folder, move)

Copy or Move a storage object to a specific folder
Parameters:
Name Type Description
folder Folder the destination folder
move boolean true: to move this storage object. false to create a copy of it
Source:

delete() → {boolean}

Delete this storage object
Source:
Returns:
- a status indicating if the folder is deleted by the storage engine
Type
boolean

exists()

Check if this object exists
Parameters:
Type Description
string the new name
Source:

reader(context) → {InputStream}

Get the reader of this storage object. Undefined if it's a folder
Parameters:
Name Type Description
context ApiContext | ApiRequest the context in which this function is called
Source:
Returns:
an InputStream object
Type
InputStream

rename(newName)

Rename this storage object
Parameters:
Name Type Description
newName string the new name
Source:

toJson(filteropt, fetchChildrenopt) → {Object}

Get a Json Object from this storage object. If it's a folder, returns direct children.
Parameters:
Name Type Attributes Description
filter function | string <optional>
a filter to apply when listing children
fetchChildren boolean <optional>
fetch also children
Source:
Returns:
a json object
Type
Object

toOutput(filteropt, altNameopt, altContentTypeopt) → {ApiOutput}

Get a ApiOutput from this storage object.
Parameters:
Name Type Attributes Description
filter function | string <optional>
a filter to apply when listing children
altName string <optional>
the name of the stream source. If not provided, the name of the storage object will be used
altContentType string <optional>
the contentType of the stream source. If not provided, the contentType of the storage object will be used
Source:
Returns:
an ApiOutput object
Type
ApiOutput

toStreamSource(altNameopt, altContentTypeopt) → {ApiStreamSource}

Get a stream source from this storage object. Undefined if this storage object is a folder
Parameters:
Name Type Attributes Description
altName string <optional>
the name of the stream source. If not provided, the name of the storage object will be used
altContentType string <optional>
the contentType of the stream source. If not provided, the contentType of the storage object will be used
Source:
Returns:
an ApiStreamSource object
Type
ApiStreamSource

update(payload, append) → {integer}

Update the content of this storage object. Doesn't apply to folders
Parameters:
Name Type Description
payload InputStream the new name
append boolean true to append to the existing content, false to overwrite
Source:
Returns:
- the number of bytes written to the storage object
Type
integer

writer(context) → {OutputStream}

Get the writer of this storage object. Undefined if it's a folder
Parameters:
Name Type Description
context ApiContext | ApiRequest the context in which this function is called
Source:
Returns:
an OutputStream object
Type
OutputStream