# Class: ResourceStorage

## ResourceStorage(xmlEditor)

The base class of objects used to load --possibly prompting user to do so-- and store document resources.

## Constructor

#### new ResourceStorage(xmlEditor)

Constructs a document resource storage object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`xmlEditor` | XMLEditor | the XML editor using this storage object.

Source:
  - res/ResourceStorage.js, line 11

### Classes

ResourceStorage

### Members

#### xmlEditor

Returns the XML editor using this storage object.

Source:
  - res/ResourceStorage.js, line 18

### Methods

#### loadResource(uri) → {Promise}

Load resource having specified URI.

Default implementation returns a `Promise` rejected with a "not implemented" error.

##### Parameters:

Name | Type | Description
--- | --- | ---
`uri` | string | absolute URI of the resource to be loaded.

Source:
  - res/ResourceStorage.js, line 32

##### Returns:

A Promise containing a Resource or `null` if specified URI is unknown to this storage object or an `Error`.

Type
  Promise

#### openResource(options) → {Promise}

Prompt user to choose an existing resource.

Default implementation returns a `Promise` rejected with a "not implemented" error.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | options for use by the resource chooser dialog box. See description in XMLEditor#openResource.

Source:
  - res/ResourceStorage.js, line 65

##### Returns:

A Promise containing a ready-to-use Resource or `null` if user canceled this operation or an `Error`.

Type
  Promise

#### storeResource(data, uri) → {Promise}

Create (or overwrite if it already exists) resource having specified URI.

Any parent directory of specified URI which does not already exist is automatically created.

Default implementation returns a `Promise` rejected with a "not implemented" error.

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Blob | the data to be stored.
`uri` | string | absolute URI of the resource to be created (or overwritten if it already exists).

Source:
  - res/ResourceStorage.js, line 50

##### Returns:

A Promise containing a Resource or `null` if specified URI is unknown to this storage object or an `Error`.

Type
  Promise