Esposter
    Preparing search index...

    Class MockBlockBlobClient

    Hierarchy (View Summary)

    Implements

    • Except<BlockBlobClient, "accountName">
    Index

    Constructors

    • Parameters

      • connectionString: string
      • containerName: string
      • blobName: string

      Returns MockBlockBlobClient

    Properties

    connectionString: string
    containerName: string

    The name of the storage container the blob is associated with.

    credential: AnonymousCredential = ...

    Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the @azure/identity package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.

    name: string

    The name of the blob.

    url: string

    Encoded URL string value.

    Accessors

    • get container(): Map<string>

      Returns Map<string>

    Methods

    • Asynchronously copies a blob to a destination within the storage account. This method returns a long running operation poller that allows you to wait indefinitely until the copy is completed. You can also cancel a copy before it is completed by calling cancelOperation on the poller. Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

      In version 2012-02-12 and later, the source for a Copy Blob operation can be a committed blob in any Azure storage account. Beginning with version 2015-02-21, the source for a Copy Blob operation can be an Azure file in any Azure storage account. Only storage accounts created on or after June 7th, 2012 allow the Copy Blob operation to copy from another storage account.

      Parameters

      • copySource: string

        url to the source Azure Blob/File.

      Returns Promise<
          PollerLikeWithCancellation<
              PollOperationState<BlobBeginCopyFromURLResponse>,
              BlobBeginCopyFromURLResponse,
          >,
      >

      https://learn.microsoft.com/rest/api/storageservices/copy-blob

      import { BlobServiceClient } from "@azure/storage-blob";
      import { DefaultAzureCredential } from "@azure/identity";

      const account = "<account>";
      const blobServiceClient = new BlobServiceClient(
      `https://${account}.blob.core.windows.net`,
      new DefaultAzureCredential(),
      );

      const containerName = "<container name>";
      const blobName = "<blob name>";
      const containerClient = blobServiceClient.getContainerClient(containerName);
      const blobClient = containerClient.getBlobClient(blobName);

      // Example using automatic polling
      const automaticCopyPoller = await blobClient.beginCopyFromURL("url");
      const automaticResult = await automaticCopyPoller.pollUntilDone();

      // Example using manual polling
      const manualCopyPoller = await blobClient.beginCopyFromURL("url");
      while (!manualCopyPoller.isDone()) {
      await manualCopyPoller.poll();
      }
      const manualResult = manualCopyPoller.getResult();

      // Example using progress updates
      const progressUpdatesCopyPoller = await blobClient.beginCopyFromURL("url", {
      onProgress(state) {
      console.log(`Progress: ${state.copyProgress}`);
      },
      });
      const progressUpdatesResult = await progressUpdatesCopyPoller.pollUntilDone();

      // Example using a changing polling interval (default 15 seconds)
      const pollingIntervalCopyPoller = await blobClient.beginCopyFromURL("url", {
      intervalInMs: 1000, // poll blob every 1 second for copy progress
      });
      const pollingIntervalResult = await pollingIntervalCopyPoller.pollUntilDone();

      // Example using copy cancellation:
      const cancelCopyPoller = await blobClient.beginCopyFromURL("url");
      // cancel operation after starting it.
      try {
      await cancelCopyPoller.cancelOperation();
      // calls to get the result now throw PollerCancelledError
      cancelCopyPoller.getResult();
      } catch (err: any) {
      if (err.name === "PollerCancelledError") {
      console.log("The copy was cancelled.");
      }
      }
    • Writes a blob by specifying the list of block IDs that make up the blob. In order to be written as part of a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can call commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new and existing blocks together. Any blocks not specified in the block list and permanently deleted.

      Returns Promise<BlockBlobCommitBlockListResponse>

      Response data for the Block Blob Commit Block List operation.

    • Marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time with the Delete Blob operation.

      Returns Promise<BlobDeleteResponse>

    • Marks the specified blob or snapshot for deletion if it exists. The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time with the Delete Blob operation.

      Returns Promise<BlobDeleteIfExistsResponse>

    • Delete the immutablility policy on the blob.

      Returns Promise<BlobDeleteImmutabilityPolicyResponse>

    • Reads or downloads a blob from the system, including its metadata and properties. You can also call Get Blob to read a snapshot.

      • In Node.js, data returns in a Readable stream readableStreamBody
      • In browsers, data returns in a promise blobBody

      Returns Promise<BlobDownloadResponseParsed>

    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Downloads an Azure Blob in parallel to a buffer. Offset and count are optional, downloads the entire blob if they are not provided.

      Warning: Buffers can only support files up to about one gigabyte on 32-bit systems or about two gigabytes on 64-bit systems due to limitations of Node.js/V8. For blobs larger than this size, consider downloadToFile.

      Returns Promise<Buffer<ArrayBufferLike>>

    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Downloads an Azure Blob to a local file. Fails if the the given file path already exits. Offset and count are optional, pass 0 and undefined respectively to download the entire blob.

      Returns Promise<BlobDownloadResponseParsed>

      The response data for blob download operation, but with readableStreamBody set to undefined since its content is already read and written into a local file at the specified path.

    • Returns true if the Azure blob resource represented by this client exists; false otherwise.

      NOTE: use this function with care since an existing blob might be deleted by other clients or applications. Vice versa new blobs might be added by other clients or applications after this function completes.

      Returns Promise<boolean>

    • Only available for BlobClient constructed with a shared key credential.

      Generates string to sign for a Blob Service Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the shared key credential of the client.

      Returns string

      The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.

    • Only available for BlobClient constructed with a shared key credential.

      Generates a Blob Service Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the shared key credential of the client.

      Returns Promise<string>

      The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.

    • Only available for BlobClient constructed with a shared key credential.

      Generates string to sign for a Blob Service Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the input user delegation key.

      Returns string

      The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.

    • Generates a Blob Service Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the input user delegation key.

      Returns Promise<string>

      The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.

    • The Get Account Information operation returns the sku name and account kind for the specified account. The Get Account Information operation is available on service versions beginning with version 2018-03-28.

      Returns Promise<BlobGetAccountInfoResponse>

      Response data for the Service Get Account Info operation.

    • Creates a AppendBlobClient object.

      Returns AppendBlobClient

    • Get a BlobLeaseClient that manages leases on the blob.

      Returns BlobLeaseClient

      A new BlobLeaseClient object for managing leases on the blob.

    • Creates a BlockBlobClient object.

      Returns BlockBlobClient

    • Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter.

      Returns Promise<BlockBlobGetBlockListResponse>

      Response data for the Block Blob Get Block List operation.

    • Creates a PageBlobClient object.

      Returns PageBlobClient

    • Returns all user-defined metadata, standard HTTP properties, and system properties for the blob. It does not return the content of the blob.

      Returns Promise<BlobGetPropertiesResponse>

      https://learn.microsoft.com/rest/api/storageservices/get-blob-properties

      WARNING: The metadata object returned in the response will have its keys in lowercase, even if they originally contained uppercase characters. This differs from the metadata keys returned by the methods of ContainerClient that list blobs using the includeMetadata option, which will retain their original casing.

    • Gets the tags associated with the underlying blob.

      Returns Promise<BlobGetTagsResponse>

    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Quick query for a JSON or CSV formatted blob.

      Example usage (Node.js):

      import { BlobServiceClient } from "@azure/storage-blob";
      import { DefaultAzureCredential } from "@azure/identity";

      const account = "<account>";
      const blobServiceClient = new BlobServiceClient(
      `https://${account}.blob.core.windows.net`,
      new DefaultAzureCredential(),
      );

      const containerName = "<container name>";
      const blobName = "<blob name>";
      const containerClient = blobServiceClient.getContainerClient(containerName);
      const blockBlobClient = containerClient.getBlockBlobClient(blobName);

      // Query and convert a blob to a string
      const queryBlockBlobResponse = await blockBlobClient.query("select from BlobStorage");
      if (queryBlockBlobResponse.readableStreamBody) {
      const downloadedBuffer = await streamToBuffer(queryBlockBlobResponse.readableStreamBody);
      const downloaded = downloadedBuffer.toString();
      console.log(`Query blob content: ${downloaded}`);
      }

      async function streamToBuffer(readableStream: NodeJS.ReadableStream): Promise<Buffer> {
      return new Promise((resolve, reject) => {
      const chunks: Buffer[] = [];
      readableStream.on("data", (data) => {
      chunks.push(data instanceof Buffer ? data : Buffer.from(data));
      });
      readableStream.on("end", () => {
      resolve(Buffer.concat(chunks));
      });
      readableStream.on("error", reject);
      });
      }

      Returns Promise<BlobDownloadResponseModel>

    • Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag.

      Returns Promise<BlobSetTierResponse>

    • Sets system properties on the blob.

      If no value provided, or no value provided for the specified blob HTTP headers, these blob HTTP headers without a value will be cleared.

      Returns Promise<BlobSetHTTPHeadersResponse>

    • Set immutability policy on the blob.

      Returns Promise<BlobSetImmutabilityPolicyResponse>

    • Set legal hold on the blob.

      Returns Promise<BlobSetLegalHoldResponse>

    • Sets user-defined metadata for the specified blob as one or more name-value pairs.

      If no option provided, or no metadata defined in the parameter, the blob metadata will be removed.

      Returns Promise<BlobSetMetadataResponse>

    • Sets tags on the underlying blob. A blob can have up to 10 tags. Tag keys must be between 1 and 128 characters. Tag values must be between 0 and 256 characters. Valid tag key and value characters include lower and upper case letters, digits (0-9), space (' '), plus ('+'), minus ('-'), period ('.'), foward slash ('/'), colon (':'), equals ('='), and underscore ('_').

      Returns Promise<BlobSetTagsResponse>

    • Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList.

      Returns Promise<BlockBlobStageBlockResponse>

      Response data for the Block Blob Stage Block operation.

    • The Stage Block From URL operation creates a new block to be committed as part of a blob where the contents are read from a URL. This API is available starting in version 2018-03-28.

      Returns Promise<BlockBlobStageBlockFromURLResponse>

      Response data for the Block Blob Stage Block From URL operation.

    • Creates a new Block Blob where the contents of the blob are read from a given URL. This API is supported beginning with the 2020-04-08 version. Partial updates are not supported with Put Blob from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial updates to a block blob’s contents using a source URL, use stageBlockFromURL and commitBlockList.

      Returns Promise<BlockBlobPutBlobFromUrlResponse>

    • Restores the contents and metadata of soft deleted blob and any associated soft deleted snapshots. Undelete Blob is supported only on version 2017-07-29 or later.

      Returns Promise<BlobUndeleteResponse>

    • Creates a new block blob, or updates the content of an existing block blob. Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported; the content of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use stageBlock and commitBlockList.

      This is a non-parallel uploading method, please use uploadFile, uploadStream or uploadBrowserData for better performance with concurrency uploading.

      Parameters

      • body: RequestBodyType

        Blob, string, ArrayBuffer, ArrayBufferView or a function which returns a new Readable stream whose offset is from data source beginning.

      • _contentLength: number

      Returns Promise<BlockBlobUploadResponse>

      Response data for the Block Blob Upload operation.

      Example usage:

      import { BlobServiceClient } from "@azure/storage-blob";
      import { DefaultAzureCredential } from "@azure/identity";

      const account = "<account>";
      const blobServiceClient = new BlobServiceClient(
      `https://${account}.blob.core.windows.net`,
      new DefaultAzureCredential(),
      );

      const containerName = "<container name>";
      const blobName = "<blob name>";
      const containerClient = blobServiceClient.getContainerClient(containerName);
      const blockBlobClient = containerClient.getBlockBlobClient(blobName);

      const content = "Hello world!";
      const uploadBlobResponse = await blockBlobClient.upload(content, content.length);
    • ONLY AVAILABLE IN BROWSERS.

      Uploads a browser Blob/File/ArrayBuffer/ArrayBufferView object to block blob.

      When buffer length lesser than or equal to 256MB, this method will use 1 upload call to finish the upload. Otherwise, this method will call stageBlock to upload blocks, and finally call commitBlockList to commit the block list.

      A common BlockBlobParallelUploadOptions.blobHTTPHeaders option to set is blobContentType, enabling the browser to provide functionality based on file type.

      Returns Promise<BlobUploadCommonResponse>

      Response data for the Blob Upload operation.

      Use uploadData instead.

    • Uploads a Buffer(Node.js)/Blob(browsers)/ArrayBuffer/ArrayBufferView object to a BlockBlob.

      When data length is no more than the specifiled BlockBlobParallelUploadOptions.maxSingleShotSize (default is BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES), this method will use 1 upload call to finish the upload. Otherwise, this method will call stageBlock to upload blocks, and finally call commitBlockList to commit the block list.

      A common BlockBlobParallelUploadOptions.blobHTTPHeaders option to set is blobContentType, enabling the browser to provide functionality based on file type.

      Returns Promise<BlobUploadCommonResponse>

    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Uploads a local file in blocks to a block blob.

      When file size lesser than or equal to 256MB, this method will use 1 upload call to finish the upload. Otherwise, this method will call stageBlock to upload blocks, and finally call commitBlockList to commit the block list.

      Returns Promise<BlobUploadCommonResponse>

      Response data for the Blob Upload operation.

    • ONLY AVAILABLE IN NODE.JS RUNTIME.

      Uploads a Node.js Readable stream into block blob.

      PERFORMANCE IMPROVEMENT TIPS:

      • Input stream highWaterMark is better to set a same value with bufferSize parameter, which will avoid Buffer.concat() operations.

      Returns Promise<BlobUploadCommonResponse>

      Response data for the Blob Upload operation.

    • Creates a new BlobClient object identical to the source but with the specified snapshot timestamp. Provide "" will remove the snapshot and return a Client to the base blob.

      Returns BlockBlobClient

      A new BlobClient object identical to the source but with the specified snapshot timestamp

    • Creates a new BlobClient object pointing to a version of this blob. Provide "" will remove the versionId and return a Client to the base blob.

      Returns BlobClient

      A new BlobClient object pointing to the version of this blob.