@azure/storage-common package

Classes

AnonymousCredential

AnonymousCredential provides a credentialPolicyCreator member used to create AnonymousCredentialPolicy objects. AnonymousCredentialPolicy is used with HTTP(S) requests that read public resources or for use with Shared Access Signatures (SAS).

AnonymousCredentialPolicy

AnonymousCredentialPolicy is used with HTTP(S) requests that read public resources or for use with Shared Access Signatures (SAS).

BaseRequestPolicy

The base class from which all request policies derive.

BufferScheduler

This class accepts a Node.js Readable stream as input, and keeps reading data from the stream into the internal buffer structure, until it reaches maxBuffers. Every available buffer will try to trigger outgoingHandler.

The internal buffer structure includes an incoming buffer array, and a outgoing buffer array. The incoming buffer array includes the "empty" buffers can be filled with new incoming data. The outgoing array includes the filled buffers to be handled by outgoingHandler. Every above buffer size is defined by parameter bufferSize.

NUM_OF_ALL_BUFFERS = BUFFERS_IN_INCOMING + BUFFERS_IN_OUTGOING + BUFFERS_UNDER_HANDLING

NUM_OF_ALL_BUFFERS lesser than or equal to maxBuffers

PERFORMANCE IMPROVEMENT TIPS:

  1. Input stream highWaterMark is better to set a same value with bufferSize parameter, which will avoid Buffer.concat() operations.
  2. concurrency should set a smaller value than maxBuffers, which is helpful to reduce the possibility when a outgoing handler waits for the stream data. in this situation, outgoing handlers are blocked. Outgoing queue shouldn't be empty.
Credential

Credential is an abstract class for Azure Storage HTTP requests signing. This class will host an credentialPolicyCreator factory which generates CredentialPolicy.

CredentialPolicy

Credential policy used to sign HTTP(S) requests before sending. This is an abstract class.

Readable
StorageBrowserPolicy

StorageBrowserPolicy will handle differences between Node.js and browser runtime, including:

  1. Browsers cache GET/HEAD requests by adding conditional headers such as 'IF_MODIFIED_SINCE'. StorageBrowserPolicy is a policy used to add a timestamp query to GET/HEAD request URL thus avoid the browser cache.

  2. Remove cookie header for security

  3. Remove content-length header to avoid browsers warning

In Node.js, this policy is a no-op pass-through.

StorageBrowserPolicyFactory

StorageBrowserPolicyFactory is a factory class helping generating StorageBrowserPolicy objects.

StorageCRC64Calculator

Class used to calculator CRC64 checksum

StorageRetryPolicy

Retry policy with exponential retry and linear retry implemented.

StorageRetryPolicyFactory

StorageRetryPolicyFactory is a factory class helping generating StorageRetryPolicy objects.

StorageSharedKeyCredential

ONLY AVAILABLE IN NODE.JS RUNTIME.

StorageSharedKeyCredential for account key authorization of Azure Storage service.

StorageSharedKeyCredentialPolicy

StorageSharedKeyCredentialPolicy is a policy used to sign HTTP request with a shared key.

UserDelegationKeyCredential

ONLY AVAILABLE IN NODE.JS RUNTIME.

UserDelegationKeyCredential is only used for generation of user delegation SAS.

See https://learn.microsoft.com/rest/api/storageservices/create-user-delegation-sas

Interfaces

NodeJSReadableStream

A Node.js Readable stream that also has a destroy method.

StorageRetryOptions

Storage Blob retry options interface.

StorageSharedKeyCredentialPolicyOptions

Options used to configure StorageSharedKeyCredentialPolicy.

StructuredMessageDecodingStreamOptions

Options used when creating StructuredMessageDecodingStream

StructuredMessageEncodingStreamOptions

Options used when creating StructuredMessageEncodingStream

UserDelegationKey

A user delegation key.

Type Aliases

CredentialPolicyCreator

A factory function that creates a new CredentialPolicy that uses the provided nextPolicy.

OutgoingHandler

OutgoingHandler is an async function triggered by BufferScheduler.

Enums

StorageRetryPolicyType

RetryPolicy types.

Functions

NewRetryPolicyFactory(StorageRetryOptions)

A factory method used to generated a RetryPolicy factory.

allocBuffer(number)

Allocates a new zero-filled Buffer of the given size.

bufferFromArrayBuffer(ArrayBuffer, number, number)

Creates a Buffer from an ArrayBuffer, with optional offset and length.

createBlobFromData(Blob | ArrayBuffer | ArrayBufferView)

Creates a Blob from the given data. Uses an indirect constructor reference to work around React Native's restrictive Blob type definitions (which only accept string | Blob, not ArrayBuffer).

getBufferLength(Buffer)

Returns the byte length of a buffer.

getCachedDefaultHttpClient()
isBuffer(unknown)

Checks whether a value is a Node.js Buffer.

storageBrowserPolicy()

storageBrowserPolicy is a policy used to prevent browsers from caching requests and to remove cookies and explicit content-length headers.

In Node.js, this policy is a no-op pass-through.

storageCorrectContentLengthPolicy()

storageCorrectContentLengthPolicy to correctly set Content-Length header with request body length.

storageRequestFailureDetailsParserPolicy()

StorageRequestFailureDetailsParserPolicy

storageRetryPolicy(StorageRetryOptions)

Retry policy with exponential retry and linear retry implemented.

storageSharedKeyCredentialPolicy(StorageSharedKeyCredentialPolicyOptions)

storageSharedKeyCredentialPolicy handles signing requests using storage account keys.

structuredMessageDecodingBrowser(Blob | ReadableStream<Uint8Array>)

To decode structured body for CRC64 content validtion in storage downloading.

structuredMessageDecodingStream(ReadableStream, StructuredMessageDecodingStreamOptions)

To decode structured body for CRC64 content validtion in storage downloading.

structuredMessageEncoding(RequestBodyType, number)

To encode structured body for CRC64 content validtion in storage uploading.

Variables

storageBrowserPolicyName

The programmatic identifier of the StorageBrowserPolicy.

storageCorrectContentLengthPolicyName

The programmatic identifier of the storageCorrectContentLengthPolicy.

storageRequestFailureDetailsParserPolicyName

The programmatic identifier of the StorageRequestFailureDetailsParserPolicy.

storageRetryPolicyName

Name of the storageRetryPolicy

storageSharedKeyCredentialPolicyName

The programmatic identifier of the storageSharedKeyCredentialPolicy.

Function Details

NewRetryPolicyFactory(StorageRetryOptions)

A factory method used to generated a RetryPolicy factory.

function NewRetryPolicyFactory(retryOptions?: StorageRetryOptions): RequestPolicyFactory

Parameters

retryOptions
StorageRetryOptions

Returns

allocBuffer(number)

Allocates a new zero-filled Buffer of the given size.

function allocBuffer(size: number): NodeBuffer

Parameters

size

number

Returns

NodeBuffer

bufferFromArrayBuffer(ArrayBuffer, number, number)

Creates a Buffer from an ArrayBuffer, with optional offset and length.

function bufferFromArrayBuffer(ab: ArrayBuffer, byteOffset?: number, length?: number): NodeBuffer

Parameters

ab

ArrayBuffer

byteOffset

number

length

number

Returns

NodeBuffer

createBlobFromData(Blob | ArrayBuffer | ArrayBufferView)

Creates a Blob from the given data. Uses an indirect constructor reference to work around React Native's restrictive Blob type definitions (which only accept string | Blob, not ArrayBuffer).

function createBlobFromData(data: Blob | ArrayBuffer | ArrayBufferView): Blob

Parameters

data

Blob | ArrayBuffer | ArrayBufferView

Returns

Blob

getBufferLength(Buffer)

Returns the byte length of a buffer.

function getBufferLength(buffer: Buffer): number

Parameters

buffer

Buffer

Returns

number

getCachedDefaultHttpClient()

function getCachedDefaultHttpClient(): HttpClient

Returns

isBuffer(unknown)

Checks whether a value is a Node.js Buffer.

function isBuffer(value: unknown): value

Parameters

value

unknown

Returns

value

storageBrowserPolicy()

storageBrowserPolicy is a policy used to prevent browsers from caching requests and to remove cookies and explicit content-length headers.

In Node.js, this policy is a no-op pass-through.

function storageBrowserPolicy(): PipelinePolicy

Returns

storageCorrectContentLengthPolicy()

storageCorrectContentLengthPolicy to correctly set Content-Length header with request body length.

function storageCorrectContentLengthPolicy(): PipelinePolicy

Returns

storageRequestFailureDetailsParserPolicy()

StorageRequestFailureDetailsParserPolicy

function storageRequestFailureDetailsParserPolicy(): PipelinePolicy

Returns

storageRetryPolicy(StorageRetryOptions)

Retry policy with exponential retry and linear retry implemented.

function storageRetryPolicy(options?: StorageRetryOptions): PipelinePolicy

Parameters

Returns

storageSharedKeyCredentialPolicy(StorageSharedKeyCredentialPolicyOptions)

storageSharedKeyCredentialPolicy handles signing requests using storage account keys.

function storageSharedKeyCredentialPolicy(options: StorageSharedKeyCredentialPolicyOptions): PipelinePolicy

Parameters

Returns

structuredMessageDecodingBrowser(Blob | ReadableStream<Uint8Array>)

To decode structured body for CRC64 content validtion in storage downloading.

function structuredMessageDecodingBrowser(source: Blob | ReadableStream<Uint8Array>): Promise<Blob>

Parameters

source

Blob | ReadableStream<Uint8Array>

Returns

Promise<Blob>

structuredMessageDecodingStream(ReadableStream, StructuredMessageDecodingStreamOptions)

To decode structured body for CRC64 content validtion in storage downloading.

function structuredMessageDecodingStream(source: ReadableStream, options: StructuredMessageDecodingStreamOptions): NodeJS.ReadableStream

Parameters

source

ReadableStream

Returns

NodeJS.ReadableStream

structuredMessageEncoding(RequestBodyType, number)

To encode structured body for CRC64 content validtion in storage uploading.

function structuredMessageEncoding(source: RequestBodyType, contentLength: number): Promise<{ body: HttpRequestBody, encodedContentLength: number }>

Parameters

contentLength

number

Returns

Promise<{ body: HttpRequestBody, encodedContentLength: number }>

Variable Details

storageBrowserPolicyName

The programmatic identifier of the StorageBrowserPolicy.

storageBrowserPolicyName: "storageBrowserPolicy"

Type

"storageBrowserPolicy"

storageCorrectContentLengthPolicyName

The programmatic identifier of the storageCorrectContentLengthPolicy.

storageCorrectContentLengthPolicyName: "StorageCorrectContentLengthPolicy"

Type

"StorageCorrectContentLengthPolicy"

storageRequestFailureDetailsParserPolicyName

The programmatic identifier of the StorageRequestFailureDetailsParserPolicy.

storageRequestFailureDetailsParserPolicyName: "storageRequestFailureDetailsParserPolicy"

Type

"storageRequestFailureDetailsParserPolicy"

storageRetryPolicyName

Name of the storageRetryPolicy

storageRetryPolicyName: "storageRetryPolicy"

Type

"storageRetryPolicy"

storageSharedKeyCredentialPolicyName

The programmatic identifier of the storageSharedKeyCredentialPolicy.

storageSharedKeyCredentialPolicyName: "storageSharedKeyCredentialPolicy"

Type

"storageSharedKeyCredentialPolicy"