# Class StorageInstance

Base class for all SDK objects.

This class provides a base implementation for all SDK objects. It handles event emission, promise management, and initialization.

This object is used to ensure that an SRE instance is initialized, and if not, create one with default settings.

#### Hierarchy (View Summary)

- SDKObject
  - StorageInstance

- Defined in src/Storage/StorageInstance.class.ts:15

##### Index

### Constructors

constructor

### Properties

_readyPromise

### Accessors

fs
ready

### Methods

delete
emit
exists
init
initSignal
off
on
once
read
removeListener
write

## Constructors

### constructor

- new StorageInstance(
  providerId?: TStorageProvider,
  storageSettings?: any,
  candidate?: AccessCandidate,
  ): StorageInstance

  #### Parameters

  - `Optional` providerId: TStorageProvider
  - storageSettings: any = {}
  - `Optional` candidate: AccessCandidate

  #### Returns StorageInstance

  Overrides SDKObject.constructor

  - Defined in src/Storage/StorageInstance.class.ts:26

## Properties

### `Protected`_readyPromise

_readyPromise: ControlledPromise<any>

Inherited from SDKObject._readyPromise

- Defined in src/Core/SDKObject.class.ts:17

## Accessors

### fs

- get fs(): SmythFS

  #### Returns SmythFS

  - Defined in src/Storage/StorageInstance.class.ts:22

### ready

- get ready(): ControlledPromise<any>

  #### Returns ControlledPromise<any>

  Inherited from SDKObject.ready

  - Defined in src/Core/SDKObject.class.ts:19

## Methods

### delete

- delete(resourceName: string): Promise<string>

  Delete a resource from the storage

  #### Parameters

  - resourceName: string

    The name or smythfs:// uri of the resource to delete

  #### Returns Promise<string>

  SmythFS URI of the deleted resource in the format (smythfs://./)

  - Defined in src/Storage/StorageInstance.class.ts:121

### emit

- emit(event: string, ...args: any[]): void

  #### Parameters

  - event: string
  - ...args: any[]

  #### Returns void

  Inherited from SDKObject.emit

  - Defined in src/Core/SDKObject.class.ts:45

### exists

- exists(resourceName: string): Promise<string>

  Check if a resource exists in the storage

  #### Parameters

  - resourceName: string

    The name or smythfs:// uri of the resource to check

  #### Returns Promise<string>

  true if the resource exists, false otherwise

  - Defined in src/Storage/StorageInstance.class.ts:137

### `Protected` init

- init(revolveReadyPromise?: boolean): Promise<void>

  #### Parameters

  - revolveReadyPromise: boolean = true

  #### Returns Promise<void>

  Inherited from SDKObject.init

  - Defined in src/Core/SDKObject.class.ts:30

### `Protected` initSignal

- initSignal(): Promise<void>

  #### Returns Promise<void>

  Inherited from SDKObject.initSignal

  - Defined in src/Core/SDKObject.class.ts:37

### off

- off(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.off

  - Defined in src/Core/SDKObject.class.ts:49

### on

- on(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.on

  - Defined in src/Core/SDKObject.class.ts:41

### once

- once(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.once

  - Defined in src/Core/SDKObject.class.ts:53

### read

- read(resourceName: string): Promise<Buffer<ArrayBufferLike>>

  Read a resource from the storage

  #### Parameters

  - resourceName: string

    The name or smythfs:// uri of the resource to read

  #### Returns Promise<Buffer<ArrayBufferLike>>

  the resource data

  - Defined in src/Storage/StorageInstance.class.ts:89

### removeListener

- removeListener(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.removeListener

  - Defined in src/Core/SDKObject.class.ts:56

### write

- write(resourceName: string, data: StorageData): Promise<string>

  Write a resource to the storage

  #### Parameters

  - resourceName: string

    The name or smythfs:// uri of the resource to write

  - data: StorageData

    The data to write to the resource

  #### Returns Promise<string>

  SmythFS URI of the written resource in the format (smythfs://./)

  - Defined in src/Storage/StorageInstance.class.ts:105