An open API service indexing awesome lists of open source software.

https://github.com/elastos/elastos.hive.cordova.sdk


https://github.com/elastos/elastos.hive.cordova.sdk

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

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.

```js
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(hivePlugin);
}
```
---

## Installation

```bash
cordova plugin add elastos-cordova-plugin-hive
```

## Supported Platforms

- Android
- iOS

# API Reference

## Classes


File


Directory


Drive


Client


## File
**Kind**: global class

* [File](#File)
* [new File()](#new_File_new)
* [.getLastInfo(onSuccess, onError)](#File+getLastInfo) ⇒
* [.getInfo()](#File+getInfo) ⇒
* [.moveTo(destPath)](#File+moveTo) ⇒
* [.copyTo(newPath)](#File+copyTo) ⇒
* [.deleteItem()](#File+deleteItem) ⇒
* [.readData(length)](#File+readData) ⇒
* [.writeData(data)](#File+writeData) ⇒
* [.commit()](#File+commit) ⇒
* [.discard(onSuccess)](#File+discard) ⇒

### 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](#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](#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](#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](#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](#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](#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](#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](#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](#File)
**Returns**: onSuccess will be called on success.

| Param | Type | Description |
| --- | --- | --- |
| onSuccess | function | The function to call on success. |

## Directory
**Kind**: global class

* [Directory](#Directory)
* [new Directory()](#new_Directory_new)
* [.getLastInfo(onSuccess, onError)](#Directory+getLastInfo) ⇒
* [.getInfo()](#Directory+getInfo) ⇒
* [.createDirectory(name)](#Directory+createDirectory) ⇒
* [.getDirectory(name)](#Directory+getDirectory) ⇒
* [.createFile(name)](#Directory+createFile) ⇒
* [.getFile(name)](#Directory+getFile) ⇒
* [.getChildren()](#Directory+getChildren) ⇒
* [.moveTo(destPath)](#Directory+moveTo) ⇒
* [.copyTo(newPath)](#Directory+copyTo) ⇒
* [.deleteItem()](#Directory+deleteItem) ⇒

### 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](#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](#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](#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](#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](#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](#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](#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](#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](#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](#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

* [Drive](#Drive)
* [new Drive()](#new_Drive_new)
* [.getLastInfo(onSuccess, onError)](#Drive+getLastInfo) ⇒
* [.getInfo()](#Drive+getInfo) ⇒
* [.rootDirctory()](#Drive+rootDirctory) ⇒
* [.createDirectory(path)](#Drive+createDirectory) ⇒
* [.getDirectory(path)](#Drive+getDirectory) ⇒
* [.createFile(path)](#Drive+createFile) ⇒
* [.getFile(path)](#Drive+getFile) ⇒
* [.getItemInfo(path)](#Drive+getItemInfo) ⇒

### 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](#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](#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](#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](#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](#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](#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](#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](#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

* [Client](#Client)
* [new Client()](#new_Client_new)
* [.login(onSuccess, onError, handler)](#Client+login) ⇒
* [.logout(onSuccess, onError)](#Client+logout) ⇒
* [.getLastInfo(onSuccess, onError)](#Client+getLastInfo) ⇒
* [.getInfo()](#Client+getInfo) ⇒
* [.getDefDrive()](#Client+getDefDrive) ⇒

### new Client()
The class representing Client.

### client.login(onSuccess, onError, handler) ⇒
Associate a user with the Client.

**Kind**: instance method of [Client](#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](#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](#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](#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](#Client)
**Returns**: A drive will be returned on success, otherwise a promise object that contains
error information will be returned.