Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AzureStorageProvider

Client to interact with Azure Blob Storage.

Hierarchy

  • StorageProvider
    • AzureStorageProvider

Index

Constructors

constructor

Properties

Protected _client

_client: Azure.BlobService

Protected _provider

_provider: string

client

client: any

Returns an instance of the client object, to interact with the cloud provider directly

returns

Client object

provider

provider: string

Returns the name of the provider

returns

Provider name

Methods

Private _createContainerInternal

  • Create a container on the server, choosing whether to use the "ifNotExists" method or not

    async

    Parameters

    • container: string

      Name of the container

    • ifNotExists: boolean

      If true, use the "ifNotExists" method variant

    • Optional options: AzureStorageCreateContainerOptions

      Dictionary with options for creating the container, including the access level (defaults to 'none' if not specified)

    Returns Promise<void>

    Promise that resolves once the container has been created. The promise doesn't contain any meaningful return value.

createContainer

  • Create a container on the server.

    async

    Parameters

    • container: string

      Name of the container

    • Optional options: AzureStorageCreateContainerOptions

      Dictionary with options for creating the container, including the access level (defaults to 'none' if not specified)

    Returns Promise<void>

    Promise that resolves once the container has been created. The promise doesn't contain any meaningful return value.

deleteContainer

  • deleteContainer(container: string): Promise<void>
  • Removes a container from the server

    async

    Parameters

    • container: string

      Name of the container

    Returns Promise<void>

    Promise that resolves once the container has been removed

deleteObject

  • deleteObject(container: string, path: string): Promise<void>
  • Removes an object from the server

    async

    Parameters

    • container: string

      Name of the container

    • path: string

      Path of the object, inside the container

    Returns Promise<void>

    Promise that resolves once the object has been removed

ensureContainer

  • Create a container on the server if it doesn't already exist.

    async

    Parameters

    • container: string

      Name of the container

    • Optional options: AzureStorageCreateContainerOptions

      Dictionary with options for creating the container, including the access level (defaults to 'none' if not specified)

    Returns Promise<void>

    Promise that resolves once the container has been created

getObject

  • getObject(container: string, path: string): Promise<Stream>
  • Requests an object from the server. The method returns a Promise that resolves to a Readable Stream containing the data.

    async

    Parameters

    • container: string

      Name of the container

    • path: string

      Path of the object, inside the container

    Returns Promise<Stream>

    Readable Stream containing the object's data

getObjectAsBuffer

  • getObjectAsBuffer(container: string, path: string): Promise<Buffer>
  • Requests an object from the server. The method returns a Promise that resolves to a Buffer object containing the data from the server.

    async

    Parameters

    • container: string

      Name of the container

    • path: string

      Path of the object, inside the container

    Returns Promise<Buffer>

    Buffer containing the object's data

getObjectAsString

  • getObjectAsString(container: string, path: string, encoding?: string): Promise<string>
  • Requests an object from the server. The method returns a Promise that resolves to a string containing the data from the server.

    async

    Parameters

    • container: string

      Name of the container

    • path: string

      Path of the object, inside the container

    • Optional encoding: string

      Optional encoding for the string; defaults to utf8

    Returns Promise<string>

    String containing the object's data

isContainer

  • isContainer(container: string): Promise<boolean>
  • Check if a container exists.

    async

    Parameters

    • container: string

      Name of the container

    Returns Promise<boolean>

    Promises that resolves with a boolean indicating if the container exists.

listContainers

  • listContainers(): Promise<string[]>
  • Lists all containers belonging to the user

    async

    Returns Promise<string[]>

    Promise that resolves with an array of all the containers

listObjects

  • listObjects(container: string, prefix?: string): Promise<ListResults>
  • Returns a list of objects with a given prefix (folder). The list is not recursive, so prefixes (folders) are returned as such.

    async

    Parameters

    • container: string

      Name of the container

    • Optional prefix: string

      Prefix (folder) inside which to list objects

    Returns Promise<ListResults>

    List of elements returned by the server

presignedGetUrl

  • presignedGetUrl(container: string, path: string, ttl?: number): Promise<string>
  • Returns a URL that clients (e.g. browsers) can use to request an object from the server with a GET request, even if the object is private.

    async

    Parameters

    • container: string

      Name of the container

    • path: string

      Path of the object, inside the container

    • Optional ttl: number

      Expiry time of the URL, in seconds (default: 1 day)

    Returns Promise<string>

    Promise that resolves with the pre-signed URL for GET requests

presignedPutUrl

  • presignedPutUrl(container: string, path: string, options?: PutObjectOptions, ttl?: number): Promise<string>
  • Returns a URL that clients (e.g. browsers) can use for PUT operations on an object in the server, even if the object is private.

    Notes on using presigned URLs to upload files to Azure Storage using PUT:

    1. The maximum file size is 100MB; larger files will trigger an error.
    2. You need to set the X-MS-Blob-Type: BlockBlob header for uploads to succeed
    async

    Parameters

    • container: string

      Name of the container

    • path: string

      Path where to store the object, inside the container

    • Optional options: PutObjectOptions

      Key-value pair of options used by providers, including the metadata dictionary

    • Optional ttl: number

      Expiry time of the URL, in seconds (default: 1 day)

    Returns Promise<string>

    Promise that resolves with the pre-signed URL for GET requests

Private presignedUrl

  • presignedUrl(operation: "getObject" | "putObject", container: string, path: string, contentSettings?: any, ttl?: number): Promise<string>
  • Returns a presigned URL for the specific operation.

    async

    Parameters

    • operation: "getObject" | "putObject"

      Operation: "getObject" or "putObject"

    • container: string

      Name of the container

    • path: string

      Path of the target object, inside the container

    • Optional contentSettings: any

      Additional headers that are required

    • Optional ttl: number

      Expiry time of the URL, in seconds (default: 1 day)

    Returns Promise<string>

    Promise that resolves with the pre-signed URL for the specified operation

putObject

  • putObject(container: string, path: string, data: Stream | string | Buffer, options?: PutObjectOptions): Promise<void>
  • Uploads a stream to the object storage server

    async

    Parameters

    • container: string

      Name of the container

    • path: string

      Path where to store the object, inside the container

    • data: Stream | string | Buffer

      Object data or stream. Can be a Stream (Readable Stream), Buffer or string.

    • Optional options: PutObjectOptions

      Key-value pair of options used by providers, including the metadata dictionary

    Returns Promise<void>

    Promise that resolves once the object has been uploaded

Generated using TypeDoc