Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Storage

Hierarchy

  • Storage

Index

Constructors

constructor

Properties

userSession

userSession: UserSession

Methods

deleteFile

  • deleteFile(path: string, options?: undefined | { wasSigned?: undefined | false | true }): Promise<void>
  • 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>
  • 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>
  • Retrieves the specified file from the app's data store.

    Parameters

    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>
  • 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>

getFileUrl

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

    Parameters

    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>
  • 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>
  • 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>
  • 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>
  • 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>
  • 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