@elastosfoundation/elastos-cordova-plugin-hive
v1.0.23
Published
Elastos Hive Plugin
Downloads
59
Readme
title: hive description: The Hive javascript API.
elastos-cordova-plugin-hive
This plugin defines a global cordova.hivePlugin
object, which provides an API for hive library.
Although in the global scope, it is not available until after the deviceready
event.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(hivePlugin);
}
Installation
cordova plugin add elastos-cordova-plugin-hive
Supported Platforms
- Android
- iOS
API Reference
Classes
File
Kind: global class
new File()
The class representing File.
file.getLastInfo(onSuccess, onError) ⇒
Get the information(ID, name size, type) of the file got last time.
Kind: instance method of File Returns: onSuccess will be called on success, otherwise onError will be called.
| Param | Type | Description | | --- | --- | --- | | onSuccess | function | The function to call on success. | | onError | function | The function to call on error. |
file.getInfo() ⇒
Get the information(ID, name, size, type) of the file from the server.
Kind: instance method of File Returns: A promise object that contains the information(ID, name, size, type) of the file will be returned on success, otherwise a promise object that contains error information will be returned.
file.moveTo(destPath) ⇒
Move to a new path.
Kind: instance method of File Returns: A promise object that contains success information will be returned on success, otherwise a promise object that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | destPath | string | The new path. |
file.copyTo(newPath) ⇒
Copy to a new path.
Kind: instance method of File Returns: A promise object that contains success information will be returned on success, otherwise a promise object that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | newPath | string | The new path. |
file.deleteItem() ⇒
Delete.
Kind: instance method of File Returns: A promise object that contains success information will be returned on success, otherwise a promise object that contains error information will be returned.
file.readData(length) ⇒
Read data of a specified length sequentially.
Kind: instance method of File Returns: A promise object that contains success information will be returned on success, otherwise a promise object that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | length | number | The length of data to write. |
file.writeData(data) ⇒
Write local change on File.
Kind: instance method of File Returns: A promise object that contains success information will be returned on success, otherwise a promise object that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | data | string | The data to write. |
file.commit() ⇒
Commit local change on File to backend.
Kind: instance method of File Returns: A promise object that contains success information will be returned on success, otherwise a promise object that contains error information will be returned.
file.discard(onSuccess) ⇒
Discard local change on File.
Kind: instance method of File Returns: onSuccess will be called on success.
| Param | Type | Description | | --- | --- | --- | | onSuccess | function | The function to call on success. |
Directory
Kind: global class
new Directory()
The class representing Directory.
directory.getLastInfo(onSuccess, onError) ⇒
Get the information(ID, name, childCount) of the directory got last time.
Kind: instance method of Directory Returns: onSuccess will be called on success, otherwise onError will be called.
| Param | Type | Description | | --- | --- | --- | | onSuccess | function | The function to call on success. | | onError | function | The function to call on error. |
directory.getInfo() ⇒
Get the information(ID, name, childCount) of the directory from the server.
Kind: instance method of Directory Returns: A promise object that contains the information(ID, name, childCount) of the file will be returned on success, otherwise a promise object that contains error information will be returned.
directory.createDirectory(name) ⇒
Create directory with name.
Kind: instance method of Directory Returns: A directory will be returned on success, otherwise a promise object that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | name | string | The directory name. |
directory.getDirectory(name) ⇒
Get the directory with a specified name.
Kind: instance method of Directory Returns: A directory will be returned on success, otherwise a promise object that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | name | string | The directory name. |
directory.createFile(name) ⇒
Create file with name.
Kind: instance method of Directory Returns: A file will be returned on success, otherwise a promise object that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | name | string | The file name. |
directory.getFile(name) ⇒
Get the File with a specified name.
Kind: instance method of Directory Returns: A file will be returned on success, otherwise a promise object that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | name | string | The file name. |
directory.getChildren() ⇒
Get children for current directory.
Kind: instance method of Directory Returns: The children for current directory will be returned on success, otherwise a promise object that contains error information will be returned.
directory.moveTo(destPath) ⇒
Move to a new path.
Kind: instance method of Directory Returns: A promise object that contains success information will be returned on success, otherwise a promise object that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | destPath | string | The destination path. |
directory.copyTo(newPath) ⇒
Copy to a new path.
Kind: instance method of Directory Returns: A promise object that contains success information will be returned on success, otherwise a promise object that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | newPath | string | The new path. |
directory.deleteItem() ⇒
Delete.
Kind: instance method of Directory Returns: A promise object that contains success information will be returned on success, otherwise a promise object that contains error information will be returned.
Drive
Kind: global class
new Drive()
The class representing Drive.
drive.getLastInfo(onSuccess, onError) ⇒
Get the information(ID) of the drive got last time.
Kind: instance method of Drive Returns: onSuccess will be called on success, otherwise onError will be called.
| Param | Type | Description | | --- | --- | --- | | onSuccess | function | The function to call on success. | | onError | function | The function to call on error. |
drive.getInfo() ⇒
Get the information(ID) of the drive from the server.
Kind: instance method of Drive Returns: A promise object that contains the information(ID) of the file will be returned on success, otherwise a promise that contains error information will be returned.
drive.rootDirctory() ⇒
Get the root directory.
Kind: instance method of Drive Returns: A directory will be returned on success, otherwise a promise that contains error information will be returned.
drive.createDirectory(path) ⇒
Create directory with path.
Kind: instance method of Drive Returns: A directory will be returned on success, otherwise a promise that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | path | string | The directory path. |
drive.getDirectory(path) ⇒
Get the directory with a specified path.
Kind: instance method of Drive Returns: A directory will be returned on success, otherwise a promise that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | path | string | The directory path. |
drive.createFile(path) ⇒
Create file with path.
Kind: instance method of Drive Returns: A file will be returned on success, otherwise a promise that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | path | string | The file path. |
drive.getFile(path) ⇒
Get the File with a specified path.
Kind: instance method of Drive Returns: A file will be returned on success, otherwise a promise that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | path | string | The file path. |
drive.getItemInfo(path) ⇒
Get the information(ID, name, size, type) of the drive with a specified path.
Kind: instance method of Drive Returns: A promise object that contains success information will be returned on success, otherwise a promise that contains error information will be returned.
| Param | Type | Description | | --- | --- | --- | | path | string | The drive path. |
Client
Kind: global class
new Client()
The class representing Client.
client.login(onSuccess, onError, handler) ⇒
Associate a user with the Client.
Kind: instance method of Client Returns: onSuccess will be called on success, otherwise onError will be called.
| Param | Type | Description | | --- | --- | --- | | onSuccess | function | The function to call on success. | | onError | function | The function to call on error. | | handler | function | The function to call. |
client.logout(onSuccess, onError) ⇒
Dissociate the user from the Client.
Kind: instance method of Client Returns: onSuccess will be called on success, otherwise onError will be called.
| Param | Type | Description | | --- | --- | --- | | onSuccess | function | The function to call on success. | | onError | function | The function to call on error. |
client.getLastInfo(onSuccess, onError) ⇒
Get the last associated user's information with client information.
Kind: instance method of Client Returns: onSuccess will be called on success, otherwise onError will be called.
| Param | Type | Description | | --- | --- | --- | | onSuccess | function | The function to call on success. | | onError | function | The function to call on error. |
client.getInfo() ⇒
Get associated user's information with client information.
Kind: instance method of Client Returns: A promise object that contains success information will be returned on success, otherwise a promise object that contains error information will be returned.
client.getDefDrive() ⇒
Get the current backend's Drive instance associated with the client's drive.
Kind: instance method of Client Returns: A drive will be returned on success, otherwise a promise object that contains error information will be returned.