new Folder()
Represents a Folder instance
Do not call constructor directly.
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
- Inherited From:
- Source:
(readonly) isFolder :boolean
Is this storage object a folder?
Type:
- boolean
- Inherited From:
- Source:
(readonly) length :integer
The length/size in bytes of this storage object. 0 if it's a folder
Type:
- integer
- Inherited From:
- 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
- Inherited From:
- Source:
(readonly) timestamp :Date
The lastModified date of this storage object
Type:
- Date
- Inherited From:
- Source:
Methods
addFolder(name) → {Folder}
Add a folder under this current folder
Parameters:
Name | Type | Description |
---|---|---|
name |
string | child folder name |
- Source:
Returns:
- the newly created folder
- Type
- Folder
addObject(altNameopt, streamSource) → {StorageObject}
Add a new file under this folder
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
altName |
string |
<optional> |
the name of the file or an alternative name to the one provided by the ApiStreamSource |
streamSource |
ApiStreamSource | a stream source |
- Source:
Returns:
- the newly created Storage Object
- Type
- StorageObject
contains(child) → {boolean}
Check if the object given by name exists under this folder
Parameters:
Name | Type | Description |
---|---|---|
child |
string | the child name |
- Source:
Returns:
- true/false
- Type
- boolean
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 |
- Inherited From:
- Source:
count() → {integer}
Count the total number of storage objects under this folder. Includes all sub files and folders
- Source:
Returns:
- the nuber of files and folders under this folder
- Type
- integer
delete() → {boolean}
Delete this storage object
- Inherited From:
- 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 |
- Inherited From:
- Source:
get(path) → {StorageObject}
Get a storage object under this folder, by path. It could be a file or folder
Parameters:
Name | Type | Description |
---|---|---|
path |
string | the storage object path |
- Source:
Returns:
- the Storage Object for the given path
- Type
- StorageObject
list(visitor, filteropt) → {integer}
List all storage objects under this folder
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
visitor |
function | a visitor function. | |
filter |
function | string |
<optional> |
a filter to apply when listing children |
- Source:
Returns:
- the nuber of files and folders under this folder
- Type
- integer
Examples
myFolder.list ( function (so) {
return so.isFolder;
});
myFolder.list (
function (so) {
// do something with the storage object
},
function (so) {
return so.isFolder;
}
);
myFolder.list (
function (so) {
// do something with the storage object
},
'contains:alpha'
);
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 |
- Inherited From:
- Source:
Returns:
an InputStream object
- Type
- InputStream
rename(newName)
Rename this storage object
Parameters:
Name | Type | Description |
---|---|---|
newName |
string | the new name |
- Inherited From:
- 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 |
- Inherited From:
- 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 |
- Inherited From:
- 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 |
- Inherited From:
- 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 |
- Inherited From:
- 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 |
- Inherited From:
- Source:
Returns:
an OutputStream object
- Type
- OutputStream