# Storage | Stacks.js 1.0.0 Library Reference
Documentation for Stacks.js 1.0.0 Library Reference

### Hierarchy

- Storage

## Index

### Constructors

- constructor

### Properties

- userSession

### Methods

- deleteFile
- getAppBucketUrl
- getFile
- getFileContents
- getFileSignedUnencrypted
- getFileUrl
- getGaiaAddress
- getUserAppFileUrl
- handleSignedEncryptedContents
- listFiles
- putFile

## Constructors

### constructor

- new Storage(options: StorageOptions ): Storage

- - Defined in packages/storage/src/storage.ts:108

  #### Parameters

  - ##### options: StorageOptions

  #### Returns Storage

## Properties

### userSession

userSession: UserSession

- Defined in packages/storage/src/storage.ts:108

## Methods

### deleteFile

- deleteFile(path: string, options?: undefined | { wasSigned?: undefined | false | true }): Promise<void>

- - Defined in packages/storage/src/storage.ts:608

  Deletes the specified file from the app's data store.

  #### Parameters

  - ##### path: string

    The path to the file to delete.

  - ##### Optional options: undefined | { wasSigned?: undefined | false | true }

    Optional options object.

  #### Returns Promise<void>

  Resolves when the file has been removed or rejects with an error.

### getAppBucketUrl

- getAppBucketUrl(gaiaHubUrl: string, appPrivateKey: string): Promise<string>

- - Defined in packages/storage/src/storage.ts:652

  Get the app storage bucket URL

  #### Parameters

  - ##### gaiaHubUrl: string

    the gaia hub URL

  - ##### appPrivateKey: string

    the app private key used to generate the app address

  #### Returns Promise<string>

  That resolves to the URL of the app index file or rejects if it fails

### getFile

- getFile(path: string, options?: GetFileOptions ): Promise<null | string | ArrayBuffer>

- - Defined in packages/storage/src/storage.ts:123

  Retrieves the specified file from the app's data store.

  #### Parameters

  - ##### path: string

    the path to the file to read

  - ##### Optional options: GetFileOptions

    a GetFileOptions object

  #### Returns Promise<null | string | ArrayBuffer>

  that resolves to the raw data in the file or rejects with an error

### getFileContents

- getFileContents(path: string, app: string, username: string | undefined, zoneFileLookupURL: string | undefined, forceText: boolean): Promise<string | ArrayBuffer | null>

- - Defined in packages/storage/src/storage.ts:263

  #### Parameters

  - ##### path: string

  - ##### app: string

  - ##### username: string | undefined

  - ##### zoneFileLookupURL: string | undefined

  - ##### forceText: boolean

  #### Returns Promise<string | ArrayBuffer | null>

### getFileSignedUnencrypted

- getFileSignedUnencrypted(path: string, opt: GetFileOptions ): Promise<null | string | ArrayBuffer>

- - Defined in packages/storage/src/storage.ts:305

  #### Parameters

  - ##### path: string

  - ##### opt: GetFileOptions

  #### Returns Promise<null | string | ArrayBuffer>

### getFileUrl

- getFileUrl(path: string, options?: GetFileUrlOptions ): Promise<string>

- - Defined in packages/storage/src/storage.ts:240

  Get the URL for reading a file from an app's data store.

  #### Parameters

  - ##### path: string

    the path to the file to read

  - ##### Optional options: GetFileUrlOptions

  #### Returns Promise<string>

  that resolves to the URL or rejects with an error

### getGaiaAddress

- getGaiaAddress(app: string, username?: undefined | string, zoneFileLookupURL?: undefined | string): Promise<string>

- - Defined in packages/storage/src/storage.ts:213

  #### Parameters

  - ##### app: string

  - ##### Optional username: undefined | string

  - ##### Optional zoneFileLookupURL: undefined | string

  #### Returns Promise<string>

### getUserAppFileUrl

- getUserAppFileUrl(path: string, username: string, appOrigin: string, zoneFileLookupURL?: undefined | string): Promise<string | undefined>

- - Defined in packages/storage/src/storage.ts:190

  Fetch the public read URL of a user file for the specified app.

  #### Parameters

  - ##### path: string

    the path to the file to read

  - ##### username: string

    The Blockstack ID of the user to look up

  - ##### appOrigin: string

    The app origin

  - ##### Optional zoneFileLookupURL: undefined | string

  #### Returns Promise<string | undefined>

  that resolves to the public read URL of the file or rejects with an error

### handleSignedEncryptedContents

- handleSignedEncryptedContents(path: string, storedContents: string, app: string, privateKey?: undefined | string, username?: undefined | string, zoneFileLookupURL?: undefined | string): Promise<string | Buffer>

- - Defined in packages/storage/src/storage.ts:383

  #### Parameters

  - ##### path: string

  - ##### storedContents: string

  - ##### app: string

  - ##### Optional privateKey: undefined | string

  - ##### Optional username: undefined | string

  - ##### Optional zoneFileLookupURL: undefined | string

  #### Returns Promise<string | Buffer>

### listFiles

- listFiles(callback: (name: string) => boolean): Promise<number>

- - Defined in packages/storage/src/storage.ts:759

  List the set of files in this application's Gaia storage bucket.

  #### Parameters

  - ##### callback: (name: string) => boolean

    a callback to invoke on each named file that returns `true` to continue the listing operation or `false` to end it. If the call is ended early by the callback, the last file is excluded. If an error occurs the entire call is rejected.

    - - (name: string): boolean

      - #### Parameters

        - ##### name: string

        #### Returns boolean

  #### Returns Promise<number>

  that resolves to the number of files listed

### putFile

- putFile(path: string, content: string | Buffer | ArrayBufferView | Blob, options?: PutFileOptions ): Promise<string>

- - Defined in packages/storage/src/storage.ts:454

  Stores the data provided in the app's data store to to the file specified.

  #### Parameters

  - ##### path: string

    the path to store the data in

  - ##### content: string | Buffer | ArrayBufferView | Blob

    the data to store in the file

  - ##### Optional options: PutFileOptions

    a PutFileOptions object

  #### Returns Promise<string>

  that resolves if the operation succeed and rejects if it failed

Generated using TypeDoc