diff --git a/sdk/storage/storage-blob/README.md b/sdk/storage/storage-blob/README.md index 92aa1ffa0955..e63b4980f728 100644 --- a/sdk/storage/storage-blob/README.md +++ b/sdk/storage/storage-blob/README.md @@ -165,7 +165,6 @@ async function main() { let marker; do { const listContainersResponse = await blobServiceClient.listContainersSegment( - Aborter.none, marker ); @@ -179,7 +178,7 @@ async function main() { const containerName = `newcontainer${new Date().getTime()}`; const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - const createContainerResponse = await containerClient.create(Aborter.none); + const createContainerResponse = await containerClient.create(); console.log( `Create container ${containerName} successfully`, createContainerResponse.requestId @@ -191,7 +190,6 @@ async function main() { const blobClient = BlobClient.fromContainerClient(containerClient, blobName); const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); const uploadBlobResponse = await blockBlobClient.upload( - Aborter.none, content, content.length ); @@ -204,7 +202,6 @@ async function main() { marker = undefined; do { const listBlobsResponse = await containerClient.listBlobFlatSegment( - Aborter.none, marker ); @@ -217,14 +214,14 @@ async function main() { // Get blob content from position 0 to the end // In Node.js, get downloaded data by accessing downloadBlockBlobResponse.readableStreamBody // In browsers, get downloaded data by accessing downloadBlockBlobResponse.blobBody - const downloadBlockBlobResponse = await blobClient.download(Aborter.none, 0); + const downloadBlockBlobResponse = await blobClient.download(0); console.log( "Downloaded blob content", await streamToString(downloadBlockBlobResponse.readableStreamBody) ); // Delete container - await containerClient.delete(Aborter.none); + await containerClient.delete(); console.log("deleted container"); } diff --git a/sdk/storage/storage-blob/samples/javascript/advanced.js b/sdk/storage/storage-blob/samples/javascript/advanced.js index 5fff6be96e40..27db88e63c84 100644 --- a/sdk/storage/storage-blob/samples/javascript/advanced.js +++ b/sdk/storage/storage-blob/samples/javascript/advanced.js @@ -38,7 +38,7 @@ async function main() { // Create a container const containerName = `newcontainer${new Date().getTime()}`; const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); // Create a blob const blobName = "newblob" + new Date().getTime(); @@ -47,7 +47,7 @@ async function main() { // Parallel uploading with uploadFileToBlockBlob in Node.js runtime // uploadFileToBlockBlob is only available in Node.js - await uploadFileToBlockBlob(Aborter.none, localFilePath, blockBlobClient, { + await uploadFileToBlockBlob(localFilePath, blockBlobClient, { blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -57,12 +57,12 @@ async function main() { // Parallel uploading a Readable stream with uploadStreamToBlockBlob in Node.js runtime // uploadStreamToBlockBlob is only available in Node.js await uploadStreamToBlockBlob( - Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins fs.createReadStream(localFilePath), blockBlobClient, 4 * 1024 * 1024, 20, { + abortSignal: Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins progress: ev => console.log(ev) } ); @@ -72,7 +72,7 @@ async function main() { // Uncomment following code in browsers because uploadBrowserDataToBlockBlob is only available in browsers /* const browserFile = document.getElementById("fileinput").files[0]; - await uploadBrowserDataToBlockBlob(Aborter.none, browserFile, blockBlobClient, { + await uploadBrowserDataToBlockBlob(browserFile, blockBlobClient, { blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -84,12 +84,12 @@ async function main() { const fileSize = fs.statSync(localFilePath).size; const buffer = Buffer.alloc(fileSize); await downloadBlobToBuffer( - Aborter.timeout(30 * 60 * 1000), buffer, blockBlobClient, 0, undefined, { + abortSignal: Aborter.timeout(30 * 60 * 1000), blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -98,7 +98,7 @@ async function main() { console.log("downloadBlobToBuffer success"); // Delete container - await containerClient.delete(Aborter.none); + await containerClient.delete(); console.log("deleted container"); } diff --git a/sdk/storage/storage-blob/samples/javascript/basic.js b/sdk/storage/storage-blob/samples/javascript/basic.js index 13f3ad085eae..00644bda81c1 100644 --- a/sdk/storage/storage-blob/samples/javascript/basic.js +++ b/sdk/storage/storage-blob/samples/javascript/basic.js @@ -42,7 +42,6 @@ async function main() { let marker; do { const listContainersResponse = await blobServiceClient.listContainersSegment( - Aborter.none, marker ); @@ -56,7 +55,7 @@ async function main() { const containerName = `newcontainer${new Date().getTime()}`; const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - const createContainerResponse = await containerClient.create(Aborter.none); + const createContainerResponse = await containerClient.create(); console.log( `Create container ${containerName} successfully`, createContainerResponse.requestId @@ -68,7 +67,6 @@ async function main() { const blobClient = BlobClient.fromContainerClient(containerClient, blobName); const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); const uploadBlobResponse = await blockBlobClient.upload( - Aborter.none, content, content.length ); @@ -81,7 +79,6 @@ async function main() { marker = undefined; do { const listBlobsResponse = await containerClient.listBlobFlatSegment( - Aborter.none, marker ); @@ -94,14 +91,14 @@ async function main() { // Get blob content from position 0 to the end // In Node.js, get downloaded data by accessing downloadBlockBlobResponse.readableStreamBody // In browsers, get downloaded data by accessing downloadBlockBlobResponse.blobBody - const downloadBlockBlobResponse = await blobClient.download(Aborter.none, 0); + const downloadBlockBlobResponse = await blobClient.download(0); console.log( "Downloaded blob content", await streamToString(downloadBlockBlobResponse.readableStreamBody) ); // Delete container - await containerClient.delete(Aborter.none); + await containerClient.delete(); console.log("deleted container"); } diff --git a/sdk/storage/storage-blob/samples/typescript/advanced.ts b/sdk/storage/storage-blob/samples/typescript/advanced.ts index 1202159d0f68..14992893f1c1 100644 --- a/sdk/storage/storage-blob/samples/typescript/advanced.ts +++ b/sdk/storage/storage-blob/samples/typescript/advanced.ts @@ -37,7 +37,7 @@ async function main() { // Create a container const containerName = `newcontainer${new Date().getTime()}`; const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); // Create a blob const blobName = "newblob" + new Date().getTime(); @@ -46,7 +46,7 @@ async function main() { // Parallel uploading with uploadFileToBlockBlob in Node.js runtime // uploadFileToBlockBlob is only available in Node.js - await uploadFileToBlockBlob(Aborter.none, localFilePath, blockBlobClient, { + await uploadFileToBlockBlob(localFilePath, blockBlobClient, { blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -56,12 +56,12 @@ async function main() { // Parallel uploading a Readable stream with uploadStreamToBlockBlob in Node.js runtime // uploadStreamToBlockBlob is only available in Node.js await uploadStreamToBlockBlob( - Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins fs.createReadStream(localFilePath), blockBlobClient, 4 * 1024 * 1024, 20, { + abortSignal: Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins progress: ev => console.log(ev) } ); @@ -71,7 +71,7 @@ async function main() { // Uncomment following code in browsers because uploadBrowserDataToBlockBlob is only available in browsers /* const browserFile = document.getElementById("fileinput").files[0]; - await uploadBrowserDataToBlockBlob(Aborter.none, browserFile, blockBlobClient, { + await uploadBrowserDataToBlockBlob(browserFile, blockBlobClient, { blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -83,12 +83,12 @@ async function main() { const fileSize = fs.statSync(localFilePath).size; const buffer = Buffer.alloc(fileSize); await downloadBlobToBuffer( - Aborter.timeout(30 * 60 * 1000), buffer, blockBlobClient, 0, undefined, { + abortSignal: Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -97,7 +97,7 @@ async function main() { console.log("downloadBlobToBuffer success"); // Delete container - await containerClient.delete(Aborter.none); + await containerClient.delete(); console.log("deleted container"); } diff --git a/sdk/storage/storage-blob/samples/typescript/basic.ts b/sdk/storage/storage-blob/samples/typescript/basic.ts index 1a1bd3ab2daf..16ee771bb017 100644 --- a/sdk/storage/storage-blob/samples/typescript/basic.ts +++ b/sdk/storage/storage-blob/samples/typescript/basic.ts @@ -3,7 +3,6 @@ */ import { - Aborter, BlobClient, BlockBlobClient, ContainerClient, @@ -42,7 +41,6 @@ async function main() { let marker; do { const listContainersResponse: Models.ServiceListContainersSegmentResponse = await blobServiceClient.listContainersSegment( - Aborter.none, marker ); @@ -56,7 +54,7 @@ async function main() { const containerName = `newcontainer${new Date().getTime()}`; const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - const createContainerResponse = await containerClient.create(Aborter.none); + const createContainerResponse = await containerClient.create(); console.log( `Create container ${containerName} successfully`, createContainerResponse.requestId @@ -68,7 +66,6 @@ async function main() { const blobClient = BlobClient.fromContainerClient(containerClient, blobName); const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); const uploadBlobResponse = await blockBlobClient.upload( - Aborter.none, content, content.length ); @@ -81,7 +78,6 @@ async function main() { marker = undefined; do { const listBlobsResponse: Models.ContainerListBlobFlatSegmentResponse = await containerClient.listBlobFlatSegment( - Aborter.none, marker ); @@ -95,7 +91,6 @@ async function main() { // In Node.js, get downloaded data by accessing downloadBlockBlobResponse.readableStreamBody // In browsers, get downloaded data by accessing downloadBlockBlobResponse.blobBody const downloadBlockBlobResponse: Models.BlobDownloadResponse = await blobClient.download( - Aborter.none, 0 ); console.log( @@ -104,7 +99,7 @@ async function main() { ); // Delete container - await containerClient.delete(Aborter.none); + await containerClient.delete(); console.log("deleted container"); } diff --git a/sdk/storage/storage-blob/src/Aborter.ts b/sdk/storage/storage-blob/src/Aborter.ts index 4b3d3d8e42e4..94eed6cf8fe2 100644 --- a/sdk/storage/storage-blob/src/Aborter.ts +++ b/sdk/storage/storage-blob/src/Aborter.ts @@ -14,7 +14,7 @@ import { AbortSignalLike, isNode } from "@azure/ms-rest-js"; * * @example * // Abort without timeout - * await blockBlobClient.upload(Aborter.none, buf, buf.length); + * await blockBlobClient.upload(buf, buf.length); * * @example * // Abort container create in 1000ms diff --git a/sdk/storage/storage-blob/src/AppendBlobClient.ts b/sdk/storage/storage-blob/src/AppendBlobClient.ts index bac431bc2219..4547a289537a 100644 --- a/sdk/storage/storage-blob/src/AppendBlobClient.ts +++ b/sdk/storage/storage-blob/src/AppendBlobClient.ts @@ -11,12 +11,14 @@ import { URLConstants } from "./utils/constants"; import { appendToURLPath, setURLParameter } from "./utils/utils.common"; export interface IAppendBlobCreateOptions { + abortSignal?: Aborter; accessConditions?: IBlobAccessConditions; blobHTTPHeaders?: Models.BlobHTTPHeaders; metadata?: IMetadata; } export interface IAppendBlobAppendBlockOptions { + abortSignal?: Aborter; accessConditions?: IAppendBlobAccessConditions; progress?: (progress: TransferProgressEvent) => void; transactionalContentMD5?: Uint8Array; @@ -129,16 +131,14 @@ export class AppendBlobClient extends BlobClient { * Creates a 0-length append blob. Call AppendBlock to append data to an append blob. * @see https://docs.microsoft.com/rest/api/storageservices/put-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {IAppendBlobCreateOptions} [options] * @returns {Promise} * @memberof AppendBlobClient */ public async create( - aborter: Aborter, options: IAppendBlobCreateOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.appendBlobContext.create(0, { abortSignal: aborter, @@ -153,8 +153,6 @@ export class AppendBlobClient extends BlobClient { * Commits a new block of data to the end of the existing append blob. * @see https://docs.microsoft.com/rest/api/storageservices/append-block * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {HttpRequestBody} body * @param {number} contentLength * @param {IAppendBlobAppendBlockOptions} [options] @@ -162,11 +160,11 @@ export class AppendBlobClient extends BlobClient { * @memberof AppendBlobClient */ public async appendBlock( - aborter: Aborter, body: HttpRequestBody, contentLength: number, options: IAppendBlobAppendBlockOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.appendBlobContext.appendBlock(body, contentLength, { abortSignal: aborter, diff --git a/sdk/storage/storage-blob/src/BlobClient.ts b/sdk/storage/storage-blob/src/BlobClient.ts index 78a63365b6ca..5818d7bc6c6a 100644 --- a/sdk/storage/storage-blob/src/BlobClient.ts +++ b/sdk/storage/storage-blob/src/BlobClient.ts @@ -13,6 +13,7 @@ import { DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS, URLConstants } from "./utils/const import { appendToURLPath, setURLParameter } from "./utils/utils.common"; export interface IBlobDownloadOptions { + abortSignal?: Aborter; snapshot?: string; rangeGetContentMD5?: boolean; blobAccessConditions?: IBlobAccessConditions; @@ -37,58 +38,75 @@ export interface IBlobDownloadOptions { } export interface IBlobGetPropertiesOptions { + abortSignal?: Aborter; blobAccessConditions?: IBlobAccessConditions; } export interface IBlobDeleteOptions { + abortSignal?: Aborter; blobAccessConditions?: IBlobAccessConditions; deleteSnapshots?: Models.DeleteSnapshotsOptionType; } +export interface IBlobUndeleteOptions { + abortSignal?: Aborter; +} + export interface IBlobSetHTTPHeadersOptions { + abortSignal?: Aborter; blobAccessConditions?: IBlobAccessConditions; } export interface IBlobSetMetadataOptions { + abortSignal?: Aborter; blobAccessConditions?: IBlobAccessConditions; } export interface IBlobAcquireLeaseOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IBlobReleaseLeaseOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IBlobRenewLeaseOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IBlobChangeLeaseOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IBlobBreakLeaseOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IBlobCreateSnapshotOptions { + abortSignal?: Aborter; metadata?: IMetadata; blobAccessConditions?: IBlobAccessConditions; } export interface IBlobStartCopyFromURLOptions { + abortSignal?: Aborter; metadata?: IMetadata; blobAccessConditions?: IBlobAccessConditions; sourceModifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IBlobAbortCopyFromURLOptions { + abortSignal?: Aborter; leaseAccessConditions?: Models.LeaseAccessConditions; } export interface IBlobSetTierOptions { + abortSignal?: Aborter; leaseAccessConditions?: Models.LeaseAccessConditions; } @@ -189,8 +207,6 @@ export class BlobClient extends StorageClient { * * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {number} offset From which position of the blob to download, >= 0 * @param {number} [count] How much data to be downloaded, > 0. Will download to the end when undefined * @param {IBlobDownloadOptions} [options] @@ -198,11 +214,11 @@ export class BlobClient extends StorageClient { * @memberof BlobClient */ public async download( - aborter: Aborter, offset: number, count?: number, options: IBlobDownloadOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.blobAccessConditions = options.blobAccessConditions || {}; options.blobAccessConditions.modifiedAccessConditions = options.blobAccessConditions.modifiedAccessConditions || {}; @@ -241,7 +257,6 @@ export class BlobClient extends StorageClient { } return new BlobDownloadResponse( - aborter, res, async (start: number): Promise => { const updatedOptions: Models.BlobDownloadOptionalParams = { @@ -276,6 +291,7 @@ export class BlobClient extends StorageClient { offset, res.contentLength!, { + abortSignal: aborter, maxRetryRequests: options.maxRetryRequests, progress: options.progress } @@ -287,16 +303,14 @@ export class BlobClient extends StorageClient { * for the blob. It does not return the content of the blob. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-properties * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {IBlobGetPropertiesOptions} [options] * @returns {Promise} * @memberof BlobClient */ public async getProperties( - aborter: Aborter, options: IBlobGetPropertiesOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.blobAccessConditions = options.blobAccessConditions || {}; return this.blobContext.getProperties({ abortSignal: aborter, @@ -312,16 +326,14 @@ export class BlobClient extends StorageClient { * Blob operation. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {IBlobDeleteOptions} [options] * @returns {Promise} * @memberof BlobClient */ public async delete( - aborter: Aborter, options: IBlobDeleteOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.blobAccessConditions = options.blobAccessConditions || {}; return this.blobContext.deleteMethod({ abortSignal: aborter, @@ -337,14 +349,15 @@ export class BlobClient extends StorageClient { * or later. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/undelete-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @returns {Promise} * @memberof BlobClient */ - public async undelete(aborter: Aborter): Promise { + public async undelete( + options: IBlobUndeleteOptions = {} + ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.blobContext.undelete({ - abortSignal: aborter + abortSignal: aborter || Aborter.none }); } @@ -355,8 +368,6 @@ export class BlobClient extends StorageClient { * these blob HTTP headers without a value will be cleared. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-properties * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {Models.BlobHTTPHeaders} [blobHTTPHeaders] If no value provided, or no value provided for * the specificed blob HTTP headers, these blob HTTP * headers without a value will be cleared. @@ -365,10 +376,10 @@ export class BlobClient extends StorageClient { * @memberof BlobClient */ public async setHTTPHeaders( - aborter: Aborter, blobHTTPHeaders?: Models.BlobHTTPHeaders, options: IBlobSetHTTPHeadersOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.blobAccessConditions = options.blobAccessConditions || {}; return this.blobContext.setHTTPHeaders({ abortSignal: aborter, @@ -385,8 +396,6 @@ export class BlobClient extends StorageClient { * metadata will be removed. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-metadata * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {IMetadata} [metadata] Replace existing metadata with this value. * If no value provided the existing metadata will be removed. * @param {IBlobSetMetadataOptions} [options] @@ -394,10 +403,10 @@ export class BlobClient extends StorageClient { * @memberof BlobClient */ public async setMetadata( - aborter: Aborter, metadata?: IMetadata, options: IBlobSetMetadataOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.blobAccessConditions = options.blobAccessConditions || {}; return this.blobContext.setMetadata({ abortSignal: aborter, @@ -413,8 +422,6 @@ export class BlobClient extends StorageClient { * In versions prior to 2012-02-12, the lock duration is 60 seconds. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} proposedLeaseId Can be specified in any valid GUID string format * @param {number} duration The lock duration can be 15 to 60 seconds, or can be infinite * @param {IBlobAcquireLeaseOptions} [options] @@ -422,11 +429,11 @@ export class BlobClient extends StorageClient { * @memberof BlobClient */ public async acquireLease( - aborter: Aborter, proposedLeaseId: string, duration: number, options: IBlobAcquireLeaseOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.blobContext.acquireLease({ abortSignal: aborter, duration, @@ -440,18 +447,16 @@ export class BlobClient extends StorageClient { * acquire a lease against the blob. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} leaseId * @param {IBlobReleaseLeaseOptions} [options] * @returns {Promise} * @memberof BlobClient */ public async releaseLease( - aborter: Aborter, leaseId: string, options: IBlobReleaseLeaseOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.blobContext.releaseLease(leaseId, { abortSignal: aborter, modifiedAccessConditions: options.modifiedAccessConditions @@ -462,18 +467,16 @@ export class BlobClient extends StorageClient { * To renew an existing lease. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} leaseId * @param {IBlobRenewLeaseOptions} [options] * @returns {Promise} * @memberof BlobClient */ public async renewLease( - aborter: Aborter, leaseId: string, options: IBlobRenewLeaseOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.blobContext.renewLease(leaseId, { abortSignal: aborter, modifiedAccessConditions: options.modifiedAccessConditions @@ -484,8 +487,6 @@ export class BlobClient extends StorageClient { * To change the ID of an existing lease. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} leaseId * @param {string} proposedLeaseId * @param {IBlobChangeLeaseOptions} [options] @@ -493,11 +494,11 @@ export class BlobClient extends StorageClient { * @memberof BlobClient */ public async changeLease( - aborter: Aborter, leaseId: string, proposedLeaseId: string, options: IBlobChangeLeaseOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.blobContext.changeLease(leaseId, proposedLeaseId, { abortSignal: aborter, modifiedAccessConditions: options.modifiedAccessConditions @@ -509,18 +510,16 @@ export class BlobClient extends StorageClient { * until the current lease period has expired. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {number} [breakPeriod] * @param {IBlobBreakLeaseOptions} [options] * @returns {Promise} * @memberof BlobClient */ public async breakLease( - aborter: Aborter, breakPeriod?: number, options: IBlobBreakLeaseOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.blobContext.breakLease({ abortSignal: aborter, breakPeriod, @@ -532,16 +531,14 @@ export class BlobClient extends StorageClient { * Creates a read-only snapshot of a blob. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/snapshot-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {IBlobCreateSnapshotOptions} [options] * @returns {Promise} * @memberof BlobClient */ public async createSnapshot( - aborter: Aborter, options: IBlobCreateSnapshotOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.blobAccessConditions = options.blobAccessConditions || {}; return this.blobContext.createSnapshot({ abortSignal: aborter, @@ -561,18 +558,16 @@ export class BlobClient extends StorageClient { * operation to copy from another storage account. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} copySource * @param {IBlobStartCopyFromURLOptions} [options] * @returns {Promise} * @memberof BlobClient */ public async startCopyFromURL( - aborter: Aborter, copySource: string, options: IBlobStartCopyFromURLOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.blobAccessConditions = options.blobAccessConditions || {}; options.sourceModifiedAccessConditions = options.sourceModifiedAccessConditions || {}; @@ -595,18 +590,16 @@ export class BlobClient extends StorageClient { * length and full metadata. Version 2012-02-12 and newer. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/abort-copy-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} copyId * @param {IBlobAbortCopyFromURLOptions} [options] * @returns {Promise} * @memberof BlobClient */ public async abortCopyFromURL( - aborter: Aborter, copyId: string, options: IBlobAbortCopyFromURLOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.blobContext.abortCopyFromURL(copyId, { abortSignal: aborter, leaseAccessConditions: options.leaseAccessConditions @@ -621,18 +614,16 @@ export class BlobClient extends StorageClient { * storage type. This operation does not update the blob's ETag. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tier * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {Models.AccessTier} tier * @param {IBlobSetTierOptions} [options] * @returns {Promise} * @memberof BlobClient */ public async setTier( - aborter: Aborter, tier: Models.AccessTier, options: IBlobSetTierOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return await this.blobContext.setTier(tier, { abortSignal: aborter, leaseAccessConditions: options.leaseAccessConditions diff --git a/sdk/storage/storage-blob/src/BlobDownloadResponse.ts b/sdk/storage/storage-blob/src/BlobDownloadResponse.ts index 0a62dc183f4c..4b5930d2cf77 100644 --- a/sdk/storage/storage-blob/src/BlobDownloadResponse.ts +++ b/sdk/storage/storage-blob/src/BlobDownloadResponse.ts @@ -1,6 +1,5 @@ import { HttpResponse, isNode } from "@azure/ms-rest-js"; -import { Aborter } from "./Aborter"; import * as Models from "./generated/lib/models"; import { IMetadata } from "./models"; import { IRetriableReadableStreamOptions } from "./utils/RetriableReadableStream"; @@ -433,7 +432,6 @@ export class BlobDownloadResponse implements Models.BlobDownloadResponse { /** * Creates an instance of BlobDownloadResponse. * - * @param {Aborter} aborter * @param {Models.BlobDownloadResponse} originalResponse * @param {ReadableStreamGetter} getter * @param {number} offset @@ -442,7 +440,6 @@ export class BlobDownloadResponse implements Models.BlobDownloadResponse { * @memberof BlobDownloadResponse */ public constructor( - aborter: Aborter, originalResponse: Models.BlobDownloadResponse, getter: ReadableStreamGetter, offset: number, @@ -451,7 +448,6 @@ export class BlobDownloadResponse implements Models.BlobDownloadResponse { ) { this.originalResponse = originalResponse; this.blobDownloadStream = new RetriableReadableStream( - aborter, this.originalResponse.readableStreamBody!, getter, offset, diff --git a/sdk/storage/storage-blob/src/BlobServiceClient.ts b/sdk/storage/storage-blob/src/BlobServiceClient.ts index 7d6bcd53bd56..ede16f6d54ba 100644 --- a/sdk/storage/storage-blob/src/BlobServiceClient.ts +++ b/sdk/storage/storage-blob/src/BlobServiceClient.ts @@ -5,7 +5,24 @@ import { Service } from "./generated/lib/operations"; import { Pipeline } from "./Pipeline"; import { StorageClient } from "./StorageClient"; +export interface ServiceGetPropertiesOptions { + abortSignal?: Aborter; +} + +export interface ServiceSetPropertiesOptions { + abortSignal?: Aborter; +} + +export interface ServiceGetAccountInfoOptions { + abortSignal?: Aborter; +} + +export interface ServiceGetStatisticsOptions { + abortSignal?: Aborter; +} + export interface IServiceListContainersSegmentOptions { + abortSignal?: Aborter; /** * @member {string} [prefix] Filters the results to return only containers * whose name begins with the specified prefix. @@ -79,14 +96,15 @@ export class BlobServiceClient extends StorageClient { * for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-service-properties} * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @returns {Promise} * @memberof BlobServiceClient */ - public async getProperties(aborter: Aborter): Promise { + public async getProperties( + options: ServiceGetPropertiesOptions = {} + ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.serviceContext.getProperties({ - abortSignal: aborter + abortSignal: aborter || Aborter.none }); } @@ -95,18 +113,19 @@ export class BlobServiceClient extends StorageClient { * for Storage Analytics, CORS (Cross-Origin Resource Sharing) rules and soft delete settings. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-service-properties} * + * @param {Models.StorageServiceProperties} properties * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation - * @param {Models.StorageServiceProperties} properties * @returns {Promise} * @memberof BlobServiceClient */ public async setProperties( - aborter: Aborter, - properties: Models.StorageServiceProperties + properties: Models.StorageServiceProperties, + options: ServiceSetPropertiesOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.serviceContext.setProperties(properties, { - abortSignal: aborter + abortSignal: aborter || Aborter.none }); } @@ -121,9 +140,12 @@ export class BlobServiceClient extends StorageClient { * @returns {Promise} * @memberof BlobServiceClient */ - public async getStatistics(aborter: Aborter): Promise { + public async getStatistics( + options: ServiceGetStatisticsOptions = {} + ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.serviceContext.getStatistics({ - abortSignal: aborter + abortSignal: aborter || Aborter.none }); } @@ -139,9 +161,12 @@ export class BlobServiceClient extends StorageClient { * @returns {Promise} * @memberof BlobServiceClient */ - public async getAccountInfo(aborter: Aborter): Promise { + public async getAccountInfo( + options: ServiceGetAccountInfoOptions = {} + ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.serviceContext.getAccountInfo({ - abortSignal: aborter + abortSignal: aborter || Aborter.none }); } @@ -163,10 +188,10 @@ export class BlobServiceClient extends StorageClient { * @memberof BlobServiceClient */ public async listContainersSegment( - aborter: Aborter, marker?: string, options: IServiceListContainersSegmentOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.serviceContext.listContainersSegment({ abortSignal: aborter, marker, diff --git a/sdk/storage/storage-blob/src/BlockBlobClient.ts b/sdk/storage/storage-blob/src/BlockBlobClient.ts index 6460323e3978..96e34639d211 100644 --- a/sdk/storage/storage-blob/src/BlockBlobClient.ts +++ b/sdk/storage/storage-blob/src/BlockBlobClient.ts @@ -12,6 +12,7 @@ import { URLConstants } from "./utils/constants"; import { appendToURLPath, setURLParameter } from "./utils/utils.common"; export interface IBlockBlobUploadOptions { + abortSignal?: Aborter; accessConditions?: IBlobAccessConditions; blobHTTPHeaders?: Models.BlobHTTPHeaders; metadata?: IMetadata; @@ -19,24 +20,28 @@ export interface IBlockBlobUploadOptions { } export interface IBlockBlobStageBlockOptions { + abortSignal?: Aborter; leaseAccessConditions?: Models.LeaseAccessConditions; progress?: (progress: TransferProgressEvent) => void; transactionalContentMD5?: Uint8Array; } export interface IBlockBlobStageBlockFromURLOptions { + abortSignal?: Aborter; range?: IRange; leaseAccessConditions?: Models.LeaseAccessConditions; sourceContentMD5?: Uint8Array; } export interface IBlockBlobCommitBlockListOptions { + abortSignal?: Aborter; accessConditions?: IBlobAccessConditions; blobHTTPHeaders?: Models.BlobHTTPHeaders; metadata?: IMetadata; } export interface IBlockBlobGetBlockListOptions { + abortSignal?: Aborter; leaseAccessConditions?: Models.LeaseAccessConditions; } @@ -156,8 +161,6 @@ export class BlockBlobClient extends BlobClient { * * @see https://docs.microsoft.com/rest/api/storageservices/put-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {HttpRequestBody} body Blob, string, ArrayBuffer, ArrayBufferView or a function * which returns a new Readable stream whose offset is from data source beginning. * @param {number} contentLength Length of body in bytes. Use Buffer.byteLength() to calculate body length for a @@ -167,11 +170,11 @@ export class BlockBlobClient extends BlobClient { * @memberof BlockBlobClient */ public async upload( - aborter: Aborter, body: HttpRequestBody, contentLength: number, options: IBlockBlobUploadOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.blockBlobContext.upload(body, contentLength, { abortSignal: aborter, @@ -188,8 +191,6 @@ export class BlockBlobClient extends BlobClient { * committed by a call to commitBlockList. * @see https://docs.microsoft.com/rest/api/storageservices/put-block * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} blockId A 64-byte value that is base64-encoded * @param {HttpRequestBody} body * @param {number} contentLength @@ -198,12 +199,12 @@ export class BlockBlobClient extends BlobClient { * @memberof BlockBlobClient */ public async stageBlock( - aborter: Aborter, blockId: string, body: HttpRequestBody, contentLength: number, options: IBlockBlobStageBlockOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.blockBlobContext.stageBlock(blockId, contentLength, body, { abortSignal: aborter, leaseAccessConditions: options.leaseAccessConditions, @@ -218,8 +219,6 @@ export class BlockBlobClient extends BlobClient { * This API is available starting in version 2018-03-28. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/put-block-from-url * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} blockId A 64-byte value that is base64-encoded * @param {string} sourceURL Specifies the URL of the blob. The value * may be a URL of up to 2 KB in length that specifies a blob. @@ -237,13 +236,13 @@ export class BlockBlobClient extends BlobClient { * @memberof BlockBlobClient */ public async stageBlockFromURL( - aborter: Aborter, blockId: string, sourceURL: string, offset: number, count?: number, options: IBlockBlobStageBlockFromURLOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.blockBlobContext.stageBlockFromURL(blockId, 0, sourceURL, { abortSignal: aborter, leaseAccessConditions: options.leaseAccessConditions, @@ -260,18 +259,16 @@ export class BlockBlobClient extends BlobClient { * blocks together. Any blocks not specified in the block list and permanently deleted. * @see https://docs.microsoft.com/rest/api/storageservices/put-block-list * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string[]} blocks Array of 64-byte value that is base64-encoded * @param {IBlockBlobCommitBlockListOptions} [options] * @returns {Promise} * @memberof BlockBlobClient */ public async commitBlockList( - aborter: Aborter, blocks: string[], options: IBlockBlobCommitBlockListOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.blockBlobContext.commitBlockList( { latest: blocks }, @@ -290,18 +287,16 @@ export class BlockBlobClient extends BlobClient { * using the specified block list filter. * @see https://docs.microsoft.com/rest/api/storageservices/get-block-list * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {Models.BlockListType} listType * @param {IBlockBlobGetBlockListOptions} [options] * @returns {Promise} * @memberof BlockBlobClient */ public async getBlockList( - aborter: Aborter, listType: Models.BlockListType, options: IBlockBlobGetBlockListOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; const res = await this.blockBlobContext.getBlockList(listType, { abortSignal: aborter, leaseAccessConditions: options.leaseAccessConditions diff --git a/sdk/storage/storage-blob/src/ContainerClient.ts b/sdk/storage/storage-blob/src/ContainerClient.ts index 53fb7e17e930..c28d134b37d8 100644 --- a/sdk/storage/storage-blob/src/ContainerClient.ts +++ b/sdk/storage/storage-blob/src/ContainerClient.ts @@ -10,23 +10,28 @@ import { ETagNone } from "./utils/constants"; import { appendToURLPath, truncatedISO8061Date } from "./utils/utils.common"; export interface IContainerCreateOptions { + abortSignal?: Aborter; metadata?: IMetadata; access?: Models.PublicAccessType; } export interface IContainerGetPropertiesOptions { + abortSignal?: Aborter; leaseAccessConditions?: Models.LeaseAccessConditions; } export interface IContainerDeleteMethodOptions { + abortSignal?: Aborter; containerAccessConditions?: IContainerAccessConditions; } export interface IContainerSetMetadataOptions { + abortSignal?: Aborter; containerAccessConditions?: IContainerAccessConditions; } export interface IContainerGetAccessPolicyOptions { + abortSignal?: Aborter; leaseAccessConditions?: Models.LeaseAccessConditions; } @@ -78,30 +83,37 @@ export declare type ContainerGetAccessPolicyResponse = { }; export interface IContainerSetAccessPolicyOptions { + abortSignal?: Aborter; containerAccessConditions?: IContainerAccessConditions; } export interface IContainerAcquireLeaseOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IContainerReleaseLeaseOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IContainerRenewLeaseOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IContainerBreakLeaseOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IContainerChangeLeaseOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } export interface IContainerListBlobsSegmentOptions { + abortSignal?: Aborter; /** * @member {string} [prefix] Filters the results to return only containers * whose name begins with the specified prefix. @@ -189,21 +201,20 @@ export class ContainerClient extends StorageClient { * the same name already exists, the operation fails. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-container * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {IContainerCreateOptions} [options] * @returns {Promise} * @memberof ContainerClient */ public async create( - aborter: Aborter, options: IContainerCreateOptions = {} ): Promise { + if (!options.abortSignal) { + options.abortSignal = Aborter.none; + } // Spread operator in destructuring assignments, // this will filter out unwanted properties from the response object into result object return this.containerContext.create({ - ...options, - abortSignal: aborter + ...options }); } @@ -212,20 +223,19 @@ export class ContainerClient extends StorageClient { * container. The data returned does not include the container's list of blobs. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-container-properties * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {IContainersGetPropertiesOptions} [options] * @returns {Promise} * @memberof ContainerClient */ public async getProperties( - aborter: Aborter, options: IContainerGetPropertiesOptions = {} ): Promise { if (!options.leaseAccessConditions) { options.leaseAccessConditions = {}; } + const aborter = options.abortSignal || Aborter.none; + return this.containerContext.getProperties({ abortSignal: aborter, ...options.leaseAccessConditions @@ -237,16 +247,15 @@ export class ContainerClient extends StorageClient { * contained within it are later deleted during garbage collection. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-container * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {Models.ContainersDeleteMethodOptionalParams} [options] * @returns {Promise} * @memberof ContainerClient */ public async delete( - aborter: Aborter, options: IContainerDeleteMethodOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; + if (!options.containerAccessConditions) { options.containerAccessConditions = {}; } @@ -286,8 +295,6 @@ export class ContainerClient extends StorageClient { * * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-container-metadata * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {IMetadata} [metadata] Replace existing metadata with this value. * If no value provided the existing metadata will be removed. * @param {IContainerSetMetadataOptions} [options] @@ -295,10 +302,11 @@ export class ContainerClient extends StorageClient { * @memberof ContainerClient */ public async setMetadata( - aborter: Aborter, metadata?: IMetadata, options: IContainerSetMetadataOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; + if (!options.containerAccessConditions) { options.containerAccessConditions = {}; } @@ -341,19 +349,17 @@ export class ContainerClient extends StorageClient { * * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-container-acl * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {IContainerGetAccessPolicyOptions} [options] * @returns {Promise} * @memberof ContainerClient */ public async getAccessPolicy( - aborter: Aborter, options: IContainerGetAccessPolicyOptions = {} ): Promise { if (!options.leaseAccessConditions) { options.leaseAccessConditions = {}; } + const aborter = options.abortSignal || Aborter.none; const response = await this.containerContext.getAccessPolicy({ abortSignal: aborter, @@ -395,8 +401,6 @@ export class ContainerClient extends StorageClient { * removed. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-container-acl * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {PublicAccessType} [access] * @param {ISignedIdentifier[]} [containerAcl] * @param {IContainerSetAccessPolicyOptions} [options] @@ -404,11 +408,11 @@ export class ContainerClient extends StorageClient { * @memberof ContainerClient */ public async setAccessPolicy( - aborter: Aborter, access?: Models.PublicAccessType, containerAcl?: ISignedIdentifier[], options: IContainerSetAccessPolicyOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.containerAccessConditions = options.containerAccessConditions || {}; const acl: Models.SignedIdentifier[] = []; for (const identifier of containerAcl || []) { @@ -436,8 +440,6 @@ export class ContainerClient extends StorageClient { * The lock duration can be 15 to 60 seconds, or can be infinite. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/lease-container * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} proposedLeaseId Can be specified in any valid GUID string format * @param {number} duration Must be between 15 to 60 seconds, or infinite (-1) * @param {IContainerAcquireLeaseOptions} [options] @@ -445,11 +447,11 @@ export class ContainerClient extends StorageClient { * @memberof ContainerClient */ public async acquireLease( - aborter: Aborter, proposedLeaseId: string, duration: number, options: IContainerAcquireLeaseOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.containerContext.acquireLease({ abortSignal: aborter, duration, @@ -463,18 +465,16 @@ export class ContainerClient extends StorageClient { * immediately acquire a lease against the container. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/lease-container * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} leaseId * @param {IContainerReleaseLeaseOptions} [options] * @returns {Promise} * @memberof ContainerClient */ public async releaseLease( - aborter: Aborter, leaseId: string, options: IContainerReleaseLeaseOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.containerContext.releaseLease(leaseId, { abortSignal: aborter, modifiedAccessConditions: options.modifiedAccessConditions @@ -485,18 +485,16 @@ export class ContainerClient extends StorageClient { * To renew an existing lease. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/lease-container * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} leaseId * @param {IContainerRenewLeaseOptions} [options] * @returns {Promise} * @memberof ContainerClient */ public async renewLease( - aborter: Aborter, leaseId: string, options: IContainerRenewLeaseOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.containerContext.renewLease(leaseId, { abortSignal: aborter, modifiedAccessConditions: options.modifiedAccessConditions @@ -508,18 +506,16 @@ export class ContainerClient extends StorageClient { * until the current lease period has expired. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/lease-container * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {number} period break period * @param {IContainerBreakLeaseOptions} [options] * @returns {Promise} * @memberof ContainerClient */ public async breakLease( - aborter: Aborter, period: number, options: IContainerBreakLeaseOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.containerContext.breakLease({ abortSignal: aborter, breakPeriod: period, @@ -531,8 +527,6 @@ export class ContainerClient extends StorageClient { * To change the ID of an existing lease. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/lease-container * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} leaseId * @param {string} proposedLeaseId * @param {IContainerChangeLeaseOptions} [options] @@ -540,11 +534,11 @@ export class ContainerClient extends StorageClient { * @memberof ContainerClient */ public async changeLease( - aborter: Aborter, leaseId: string, proposedLeaseId: string, options: IContainerChangeLeaseOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.containerContext.changeLease(leaseId, proposedLeaseId, { abortSignal: aborter, modifiedAccessConditions: options.modifiedAccessConditions @@ -558,18 +552,16 @@ export class ContainerClient extends StorageClient { * (passing the the previously-returned Marker) to get the next segment. * @see https://docs.microsoft.com/rest/api/storageservices/list-blobs * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} [marker] * @param {IContainerListBlobsSegmentOptions} [options] * @returns {Promise} * @memberof ContainerClient */ public async listBlobFlatSegment( - aborter: Aborter, marker?: string, options: IContainerListBlobsSegmentOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.containerContext.listBlobFlatSegment({ abortSignal: aborter, marker, @@ -584,19 +576,17 @@ export class ContainerClient extends StorageClient { * again (passing the the previously-returned Marker) to get the next segment. * @see https://docs.microsoft.com/rest/api/storageservices/list-blobs * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} delimiter * @param {IContainerListBlobsSegmentOptions} [options] * @returns {Promise} * @memberof ContainerClient */ public async listBlobHierarchySegment( - aborter: Aborter, delimiter: string, marker?: string, options: IContainerListBlobsSegmentOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.containerContext.listBlobHierarchySegment(delimiter, { abortSignal: aborter, marker, diff --git a/sdk/storage/storage-blob/src/PageBlobClient.ts b/sdk/storage/storage-blob/src/PageBlobClient.ts index 9e2a49d2d67f..ad826f480c86 100644 --- a/sdk/storage/storage-blob/src/PageBlobClient.ts +++ b/sdk/storage/storage-blob/src/PageBlobClient.ts @@ -12,6 +12,7 @@ import { URLConstants } from "./utils/constants"; import { appendToURLPath, setURLParameter } from "./utils/utils.common"; export interface IPageBlobCreateOptions { + abortSignal?: Aborter; accessConditions?: IBlobAccessConditions; blobSequenceNumber?: number; blobHTTPHeaders?: Models.BlobHTTPHeaders; @@ -19,33 +20,40 @@ export interface IPageBlobCreateOptions { } export interface IPageBlobUploadPagesOptions { + abortSignal?: Aborter; accessConditions?: IPageBlobAccessConditions; progress?: (progress: TransferProgressEvent) => void; transactionalContentMD5?: Uint8Array; } export interface IPageBlobClearPagesOptions { + abortSignal?: Aborter; accessConditions?: IPageBlobAccessConditions; } export interface IPageBlobGetPageRangesOptions { + abortSignal?: Aborter; accessConditions?: IBlobAccessConditions; } export interface IPageBlobGetPageRangesDiffOptions { + abortSignal?: Aborter; accessConditions?: IBlobAccessConditions; range?: string; } export interface IPageBlobResizeOptions { + abortSignal?: Aborter; accessConditions?: IBlobAccessConditions; } export interface IPageBlobUpdateSequenceNumberOptions { + abortSignal?: Aborter; accessConditions?: IBlobAccessConditions; } export interface IPageBlobStartCopyIncrementalOptions { + abortSignal?: Aborter; modifiedAccessConditions?: Models.ModifiedAccessConditions; } @@ -157,18 +165,16 @@ export class PageBlobClient extends BlobClient { * data to a page blob. * @see https://docs.microsoft.com/rest/api/storageservices/put-blob * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {number} size * @param {IPageBlobCreateOptions} [options] * @returns {Promise} * @memberof PageBlobClient */ public async create( - aborter: Aborter, size: number, options: IPageBlobCreateOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.pageBlobContext.create(0, size, { abortSignal: aborter, @@ -184,8 +190,6 @@ export class PageBlobClient extends BlobClient { * Writes 1 or more pages to the page blob. The start and end offsets must be a multiple of 512. * @see https://docs.microsoft.com/rest/api/storageservices/put-page * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {HttpRequestBody} body * @param {number} offset Offset of destination page blob * @param {number} count Content length of body, also how many bytes to be uploaded @@ -194,12 +198,12 @@ export class PageBlobClient extends BlobClient { * @memberof PageBlobClient */ public async uploadPages( - aborter: Aborter, body: HttpRequestBody, offset: number, count: number, options: IPageBlobUploadPagesOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.pageBlobContext.uploadPages(body, count, { abortSignal: aborter, @@ -216,8 +220,6 @@ export class PageBlobClient extends BlobClient { * Frees the specified pages from the page blob. * @see https://docs.microsoft.com/rest/api/storageservices/put-page * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {number} offset * @param {number} count * @param {IPageBlobClearPagesOptions} [options] @@ -225,11 +227,11 @@ export class PageBlobClient extends BlobClient { * @memberof PageBlobClient */ public async clearPages( - aborter: Aborter, offset: number, count: number, options: IPageBlobClearPagesOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.pageBlobContext.clearPages(0, { abortSignal: aborter, @@ -244,8 +246,6 @@ export class PageBlobClient extends BlobClient { * Returns the list of valid page ranges for a page blob or snapshot of a page blob. * @see https://docs.microsoft.com/rest/api/storageservices/get-page-ranges * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {number} offset * @param {number} count * @param {IPageBlobGetPageRangesOptions} [options] @@ -253,11 +253,11 @@ export class PageBlobClient extends BlobClient { * @memberof PageBlobClient */ public async getPageRanges( - aborter: Aborter, offset: number, count: number, options: IPageBlobGetPageRangesOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.pageBlobContext.getPageRanges({ abortSignal: aborter, @@ -271,8 +271,6 @@ export class PageBlobClient extends BlobClient { * Gets the collection of page ranges that differ between a specified snapshot and this page blob. * @see https://docs.microsoft.com/rest/api/storageservices/get-page-ranges * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {number} offset * @param {number} count * @param {string} prevSnapshot @@ -281,12 +279,12 @@ export class PageBlobClient extends BlobClient { * @memberof PageBlobClient */ public async getPageRangesDiff( - aborter: Aborter, offset: number, count: number, prevSnapshot: string, options: IPageBlobGetPageRangesDiffOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.pageBlobContext.getPageRangesDiff({ abortSignal: aborter, @@ -301,18 +299,16 @@ export class PageBlobClient extends BlobClient { * Resizes the page blob to the specified size (which must be a multiple of 512). * @see https://docs.microsoft.com/rest/api/storageservices/set-blob-properties * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {number} size * @param {IPageBlobResizeOptions} [options] * @returns {Promise} * @memberof PageBlobClient */ public async resize( - aborter: Aborter, size: number, options: IPageBlobResizeOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.pageBlobContext.resize(size, { abortSignal: aborter, @@ -325,8 +321,6 @@ export class PageBlobClient extends BlobClient { * Sets a page blob's sequence number. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-properties * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {Models.SequenceNumberActionType} sequenceNumberAction * @param {number} [sequenceNumber] Required if sequenceNumberAction is max or update * @param {IPageBlobUpdateSequenceNumberOptions} [options] @@ -334,11 +328,11 @@ export class PageBlobClient extends BlobClient { * @memberof PageBlobClient */ public async updateSequenceNumber( - aborter: Aborter, sequenceNumberAction: Models.SequenceNumberActionType, sequenceNumber?: number, options: IPageBlobUpdateSequenceNumberOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; options.accessConditions = options.accessConditions || {}; return this.pageBlobContext.updateSequenceNumber(sequenceNumberAction, { abortSignal: aborter, @@ -356,8 +350,6 @@ export class PageBlobClient extends BlobClient { * @see https://docs.microsoft.com/rest/api/storageservices/incremental-copy-blob * @see https://docs.microsoft.com/en-us/azure/virtual-machines/windows/incremental-snapshots * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} copySource Specifies the name of the source page blob snapshot. For example, * https://myaccount.blob.core.windows.net/mycontainer/myblob?snapshot= * @param {IPageBlobStartCopyIncrementalOptions} [options] @@ -365,10 +357,10 @@ export class PageBlobClient extends BlobClient { * @memberof PageBlobClient */ public async startCopyIncremental( - aborter: Aborter, copySource: string, options: IPageBlobStartCopyIncrementalOptions = {} ): Promise { + const aborter = options.abortSignal || Aborter.none; return this.pageBlobContext.copyIncremental(copySource, { abortSignal: aborter, modifiedAccessConditions: options.modifiedAccessConditions diff --git a/sdk/storage/storage-blob/src/highlevel.browser.ts b/sdk/storage/storage-blob/src/highlevel.browser.ts index 4995f3a806cc..a25ea032c50d 100644 --- a/sdk/storage/storage-blob/src/highlevel.browser.ts +++ b/sdk/storage/storage-blob/src/highlevel.browser.ts @@ -1,6 +1,5 @@ import { generateUuid } from "@azure/ms-rest-js"; -import { Aborter } from "./Aborter"; import { BlockBlobClient } from "./BlockBlobClient"; import { BlobUploadCommonResponse, IUploadToBlockBlobOptions } from "./highlevel.common"; import { Batch } from "./utils/Batch"; @@ -22,22 +21,18 @@ import { generateBlockID } from "./utils/utils.common"; * to commit the block list. * * @export - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {Blob | ArrayBuffer | ArrayBufferView} browserData Blob, File, ArrayBuffer or ArrayBufferView * @param {BlockBlobClient} blockBlobClient * @param {IUploadToBlockBlobOptions} [options] * @returns {Promise} */ export async function uploadBrowserDataToBlockBlob( - aborter: Aborter, browserData: Blob | ArrayBuffer | ArrayBufferView, blockBlobClient: BlockBlobClient, - options?: IUploadToBlockBlobOptions + options: IUploadToBlockBlobOptions = {} ): Promise { const browserBlob = new Blob([browserData]); return UploadSeekableBlobToBlockBlob( - aborter, (offset: number, size: number): Blob => { return browserBlob.slice(offset, offset + size); }, @@ -57,8 +52,6 @@ export async function uploadBrowserDataToBlockBlob( * Otherwise, this method will call stageBlock to upload blocks, and finally call commitBlockList * to commit the block list. * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {(offset: number, size: number) => Blob} blobFactory * @param {number} size * @param {BlockBlobClient} blockBlobClient @@ -66,7 +59,6 @@ export async function uploadBrowserDataToBlockBlob( * @returns {Promise} */ async function UploadSeekableBlobToBlockBlob( - aborter: Aborter, blobFactory: (offset: number, size: number) => Blob, size: number, blockBlobClient: BlockBlobClient, @@ -112,7 +104,7 @@ async function UploadSeekableBlobToBlockBlob( } if (size <= options.maxSingleShotSize) { - return blockBlobClient.upload(aborter, blobFactory(0, size), size, options); + return blockBlobClient.upload(blobFactory(0, size), size, options); } const numBlocks: number = Math.floor((size - 1) / options.blockSize) + 1; @@ -137,12 +129,13 @@ async function UploadSeekableBlobToBlockBlob( const contentLength = end - start; blockList.push(blockID); await blockBlobClient.stageBlock( - aborter, blockID, blobFactory(start, contentLength), contentLength, { - leaseAccessConditions: options.blobAccessConditions!.leaseAccessConditions + abortSignal: options.abortSignal, + leaseAccessConditions: options.blobAccessConditions! + .leaseAccessConditions } ); // Update progress after block is successfully uploaded to server, in case of block trying @@ -158,5 +151,5 @@ async function UploadSeekableBlobToBlockBlob( } await batch.do(); - return blockBlobClient.commitBlockList(aborter, blockList, options); + return blockBlobClient.commitBlockList(blockList, options); } diff --git a/sdk/storage/storage-blob/src/highlevel.common.ts b/sdk/storage/storage-blob/src/highlevel.common.ts index 19391e146b0b..73f93ff757e3 100644 --- a/sdk/storage/storage-blob/src/highlevel.common.ts +++ b/sdk/storage/storage-blob/src/highlevel.common.ts @@ -1,5 +1,6 @@ import { HttpResponse, TransferProgressEvent } from "@azure/ms-rest-js"; +import { Aborter } from "./Aborter"; import * as Models from "./generated/lib/models"; import { IBlobAccessConditions } from "./models"; @@ -10,6 +11,16 @@ import { IBlobAccessConditions } from "./models"; * @interface IUploadToBlockBlobOptions */ export interface IUploadToBlockBlobOptions { + /** + * Aborter instance to cancel request. It can be created with Aborter.none + * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples + * about request cancellation. + * + * @type {Aborter} + * @memberof IUploadToBlockBlobOptions + */ + abortSignal?: Aborter; + /** * Destination block blob size in bytes. * @@ -91,6 +102,16 @@ export type BlobUploadCommonResponse = Models.BlockBlobUploadHeaders & { * @interface IDownloadFromBlobOptions */ export interface IDownloadFromBlobOptions { + /** + * Aborter instance to cancel request. It can be created with Aborter.none + * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples + * about request cancellation. + * + * @type {Aborter} + * @memberof IUploadToBlockBlobOptions + */ + abortSignal?: Aborter; + /** * blockSize is the data every request trying to download. * Must be >= 0, if set to 0 or undefined, blockSize will automatically calculated according diff --git a/sdk/storage/storage-blob/src/highlevel.node.ts b/sdk/storage/storage-blob/src/highlevel.node.ts index c94132c126ec..9cff32403956 100644 --- a/sdk/storage/storage-blob/src/highlevel.node.ts +++ b/sdk/storage/storage-blob/src/highlevel.node.ts @@ -33,22 +33,18 @@ import { streamToBuffer } from "./utils/utils.node"; * to commit the block list. * * @export - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {string} filePath Full path of local file * @param {BlockBlobClient} blockBlobClient BlockBlobClient * @param {IUploadToBlockBlobOptions} [options] IUploadToBlockBlobOptions * @returns {(Promise)} ICommonResponse */ export async function uploadFileToBlockBlob( - aborter: Aborter, filePath: string, blockBlobClient: BlockBlobClient, - options?: IUploadToBlockBlobOptions + options: IUploadToBlockBlobOptions = {} ): Promise { const size = fs.statSync(filePath).size; return uploadResetableStreamToBlockBlob( - aborter, (offset, count) => fs.createReadStream(filePath, { autoClose: true, @@ -73,8 +69,6 @@ export async function uploadFileToBlockBlob( * to commit the block list. * * @export - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {(offset: number) => NodeJS.ReadableStream} streamFactory Returns a Node.js Readable stream starting * from the offset defined * @param {number} size Size of the block blob @@ -83,7 +77,6 @@ export async function uploadFileToBlockBlob( * @returns {(Promise)} ICommonResponse */ async function uploadResetableStreamToBlockBlob( - aborter: Aborter, streamFactory: (offset: number, count?: number) => NodeJS.ReadableStream, size: number, blockBlobClient: BlockBlobClient, @@ -129,7 +122,7 @@ async function uploadResetableStreamToBlockBlob( } if (size <= options.maxSingleShotSize) { - return blockBlobClient.upload(aborter, () => streamFactory(0), size, options); + return blockBlobClient.upload(() => streamFactory(0), size, options); } const numBlocks: number = Math.floor((size - 1) / options.blockSize) + 1; @@ -154,12 +147,13 @@ async function uploadResetableStreamToBlockBlob( const contentLength = end - start; blockList.push(blockID); await blockBlobClient.stageBlock( - aborter, blockID, () => streamFactory(start, contentLength), contentLength, { - leaseAccessConditions: options.blobAccessConditions!.leaseAccessConditions + abortSignal: options.abortSignal, + leaseAccessConditions: options.blobAccessConditions! + .leaseAccessConditions } ); // Update progress after block is successfully uploaded to server, in case of block trying @@ -172,7 +166,7 @@ async function uploadResetableStreamToBlockBlob( } await batch.do(); - return blockBlobClient.commitBlockList(aborter, blockList, options); + return blockBlobClient.commitBlockList(blockList, options); } /** @@ -182,8 +176,6 @@ async function uploadResetableStreamToBlockBlob( * Offset and count are optional, pass 0 for both to download the entire blob. * * @export - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {Buffer} buffer Buffer to be fill, must have length larger than count * @param {BlobClient} blobClient A BlobClient object * @param {number} offset From which position of the block blob to download @@ -192,7 +184,6 @@ async function uploadResetableStreamToBlockBlob( * @returns {Promise} */ export async function downloadBlobToBuffer( - aborter: Aborter, buffer: Buffer, blobClient: BlobClient, offset: number, @@ -223,7 +214,7 @@ export async function downloadBlobToBuffer( // Customer doesn't specify length, get it if (!count) { - const response = await blobClient.getProperties(aborter, options); + const response = await blobClient.getProperties(options); count = response.contentLength! - offset; if (count < 0) { throw new RangeError( @@ -243,7 +234,8 @@ export async function downloadBlobToBuffer( for (let off = offset; off < offset + count; off = off + options.blockSize) { batch.addOperation(async () => { const chunkEnd = off + options.blockSize! < count! ? off + options.blockSize! : count!; - const response = await blobClient.download(aborter, off, chunkEnd - off + 1, { + const response = await blobClient.download(off, chunkEnd - off + 1, { + abortSignal: options.abortSignal, blobAccessConditions: options.blobAccessConditions, maxRetryRequests: options.maxRetryRequestsPerBlock }); @@ -268,6 +260,16 @@ export async function downloadBlobToBuffer( * @interface IUploadStreamToBlockBlobOptions */ export interface IUploadStreamToBlockBlobOptions { + /** + * Aborter instance to cancel request. It can be created with Aborter.none + * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples + * about request cancellation. + * + * @type {Aborter} + * @memberof IUploadToBlockBlobOptions + */ + abortSignal?: Aborter; + /** * Blob HTTP Headers. * @@ -310,8 +312,6 @@ export interface IUploadStreamToBlockBlobOptions { * parameter, which will avoid Buffer.concat() operations. * * @export - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {Readable} stream Node.js Readable stream * @param {BlockBlobClient} blockBlobClient A BlockBlobClient instance * @param {number} bufferSize Size of every buffer allocated, also the block size in the uploaded block blob @@ -321,7 +321,6 @@ export interface IUploadStreamToBlockBlobOptions { * @returns {Promise} */ export async function uploadStreamToBlockBlob( - aborter: Aborter, stream: Readable, blockBlobClient: BlockBlobClient, bufferSize: number, @@ -349,7 +348,7 @@ export async function uploadStreamToBlockBlob( blockList.push(blockID); blockNum++; - await blockBlobClient.stageBlock(aborter, blockID, buffer, buffer.length, { + await blockBlobClient.stageBlock(blockID, buffer, buffer.length, { leaseAccessConditions: options.accessConditions!.leaseAccessConditions }); @@ -367,5 +366,5 @@ export async function uploadStreamToBlockBlob( ); await scheduler.do(); - return blockBlobClient.commitBlockList(aborter, blockList, options); + return blockBlobClient.commitBlockList(blockList, options); } diff --git a/sdk/storage/storage-blob/src/utils/RetriableReadableStream.ts b/sdk/storage/storage-blob/src/utils/RetriableReadableStream.ts index 5bf8bec65096..dde7987093bf 100644 --- a/sdk/storage/storage-blob/src/utils/RetriableReadableStream.ts +++ b/sdk/storage/storage-blob/src/utils/RetriableReadableStream.ts @@ -6,6 +6,16 @@ import { Aborter } from "../Aborter"; export type ReadableStreamGetter = (offset: number) => Promise; export interface IRetriableReadableStreamOptions { + /** + * Aborter instance to cancel request. It can be created with Aborter.none + * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples + * about request cancellation. + * + * @type {Aborter} + * @memberof IUploadToBlockBlobOptions + */ + abortSignal?: Aborter; + /** * Max retry count (>=0), undefined or invalid value means no retry * @@ -59,8 +69,6 @@ export class RetriableReadableStream extends Readable { /** * Creates an instance of RetriableReadableStream. * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {NodeJS.ReadableStream} source The current ReadableStream returned from getter * @param {ReadableStreamGetter} getter A method calling downloading request returning * a new ReadableStream from specified offset @@ -70,7 +78,6 @@ export class RetriableReadableStream extends Readable { * @memberof RetriableReadableStream */ public constructor( - aborter: Aborter, source: NodeJS.ReadableStream, getter: ReadableStreamGetter, offset: number, @@ -78,7 +85,7 @@ export class RetriableReadableStream extends Readable { options: IRetriableReadableStreamOptions = {} ) { super(); - this.aborter = aborter; + this.aborter = options.abortSignal || Aborter.none; this.getter = getter; this.source = source; this.start = offset; @@ -89,7 +96,7 @@ export class RetriableReadableStream extends Readable { this.progress = options.progress; this.options = options; - aborter.addEventListener("abort", () => { + this.aborter.addEventListener("abort", () => { this.source.pause(); this.emit("error", new RestError("The request was aborted", RestError.REQUEST_ABORTED_ERROR)); }); diff --git a/sdk/storage/storage-blob/test/aborter.spec.ts b/sdk/storage/storage-blob/test/aborter.spec.ts index 8fee11a21f75..ac4670a48d58 100644 --- a/sdk/storage/storage-blob/test/aborter.spec.ts +++ b/sdk/storage/storage-blob/test/aborter.spec.ts @@ -23,12 +23,12 @@ describe("Aborter", () => { }); it("Should not abort after calling abort()", async () => { - await containerClient.create(Aborter.none); + await containerClient.create({abortSignal: Aborter.none}); }); it("Should abort when calling abort() before request finishes", async () => { const aborter = Aborter.none; - const response = containerClient.create(aborter); + const response = containerClient.create({abortSignal: aborter}); aborter.abort(); try { await response; @@ -38,13 +38,13 @@ describe("Aborter", () => { it("Should not abort when calling abort() after request finishes", async () => { const aborter = Aborter.none; - await containerClient.create(aborter); + await containerClient.create({abortSignal: aborter}); aborter.abort(); }); it("Should abort after aborter timeout", async () => { try { - await containerClient.create(Aborter.timeout(1)); + await containerClient.create({abortSignal: Aborter.timeout(1)}); assert.fail(); } catch (err) {} }); @@ -52,7 +52,7 @@ describe("Aborter", () => { it("Should abort after father aborter calls abort()", async () => { try { const aborter = Aborter.none; - const response = containerClient.create(aborter.withTimeout(10 * 60 * 1000)); + const response = containerClient.create({abortSignal: aborter.withTimeout(10 * 60 * 1000)}); aborter.abort(); await response; assert.fail(); @@ -62,7 +62,7 @@ describe("Aborter", () => { it("Should abort after father aborter timeout", async () => { try { const aborter = Aborter.timeout(1); - const response = containerClient.create(aborter.withTimeout(10 * 60 * 1000)); + const response = containerClient.create({abortSignal: aborter.withTimeout(10 * 60 * 1000)}); await response; assert.fail(); } catch (err) {} diff --git a/sdk/storage/storage-blob/test/appendblobclient.spec.ts b/sdk/storage/storage-blob/test/appendblobclient.spec.ts index 16f05be0b397..b0fb8f8179cf 100644 --- a/sdk/storage/storage-blob/test/appendblobclient.spec.ts +++ b/sdk/storage/storage-blob/test/appendblobclient.spec.ts @@ -1,6 +1,5 @@ import * as assert from "assert"; -import { Aborter } from "../src/Aborter"; import { AppendBlobClient } from "../src/AppendBlobClient"; import { ContainerClient } from "../src/ContainerClient"; import { bodyToString, getBSU, getUniqueName } from "./utils"; @@ -17,18 +16,18 @@ describe("AppendBlobClient", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); blobName = getUniqueName("blob"); appendBlobClient = AppendBlobClient.fromContainerClient(containerClient, blobName); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("create with default parameters", async () => { - await appendBlobClient.create(Aborter.none); - await appendBlobClient.download(Aborter.none, 0); + await appendBlobClient.create(); + await appendBlobClient.download(0); }); it("create with parameters configured", async () => { @@ -45,8 +44,8 @@ describe("AppendBlobClient", () => { key2: "valb" } }; - await appendBlobClient.create(Aborter.none, options); - const properties = await appendBlobClient.getProperties(Aborter.none); + await appendBlobClient.create(options); + const properties = await appendBlobClient.getProperties(); assert.equal(properties.cacheControl, options.blobHTTPHeaders.blobCacheControl); assert.equal(properties.contentDisposition, options.blobHTTPHeaders.blobContentDisposition); assert.equal(properties.contentEncoding, options.blobHTTPHeaders.blobContentEncoding); @@ -57,12 +56,12 @@ describe("AppendBlobClient", () => { }); it("appendBlock", async () => { - await appendBlobClient.create(Aborter.none); + await appendBlobClient.create(); const content = "Hello World!"; - await appendBlobClient.appendBlock(Aborter.none, content, content.length); + await appendBlobClient.appendBlock(content, content.length); - const downloadResponse = await appendBlobClient.download(Aborter.none, 0); + const downloadResponse = await appendBlobClient.download(0); assert.equal(await bodyToString(downloadResponse, content.length), content); assert.equal(downloadResponse.contentLength!, content.length); }); diff --git a/sdk/storage/storage-blob/test/blobclient.spec.ts b/sdk/storage/storage-blob/test/blobclient.spec.ts index 0ae348f6c836..3386947fb963 100644 --- a/sdk/storage/storage-blob/test/blobclient.spec.ts +++ b/sdk/storage/storage-blob/test/blobclient.spec.ts @@ -1,7 +1,6 @@ import * as assert from "assert"; import { isNode } from "@azure/ms-rest-js"; -import { Aborter } from "../src/Aborter"; import { BlobClient } from "../src/BlobClient"; import { BlockBlobClient } from "../src/BlockBlobClient"; import { ContainerClient } from "../src/ContainerClient"; @@ -20,24 +19,24 @@ describe("BlobClient", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); blobName = getUniqueName("blob"); blobClient = BlobClient.fromContainerClient(containerClient, blobName); blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); - await blockBlobClient.upload(Aborter.none, content, content.length); + await blockBlobClient.upload(content, content.length); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("download with with default parameters", async () => { - const result = await blobClient.download(Aborter.none, 0); + const result = await blobClient.download(0); assert.deepStrictEqual(await bodyToString(result, content.length), content); }); it("download all parameters set", async () => { - const result = await blobClient.download(Aborter.none, 0, 1, { + const result = await blobClient.download(0, 1, { rangeGetContentMD5: true }); assert.deepStrictEqual(await bodyToString(result, 1), content[0]); @@ -48,8 +47,8 @@ describe("BlobClient", () => { a: "a", b: "b" }; - await blobClient.setMetadata(Aborter.none, metadata); - const result = await blobClient.getProperties(Aborter.none); + await blobClient.setMetadata(metadata); + const result = await blobClient.getProperties(); assert.deepStrictEqual(result.metadata, metadata); }); @@ -58,18 +57,18 @@ describe("BlobClient", () => { a: "a", b: "b" }; - await blobClient.setMetadata(Aborter.none, metadata); - const result = await blobClient.getProperties(Aborter.none); + await blobClient.setMetadata(metadata); + const result = await blobClient.getProperties(); assert.deepStrictEqual(result.metadata, metadata); - await blobClient.setMetadata(Aborter.none); - const result2 = await blobClient.getProperties(Aborter.none); + await blobClient.setMetadata(); + const result2 = await blobClient.getProperties(); assert.deepStrictEqual(result2.metadata, {}); }); it("setHTTPHeaders with default parameters", async () => { - await blobClient.setHTTPHeaders(Aborter.none, {}); - const result = await blobClient.getProperties(Aborter.none); + await blobClient.setHTTPHeaders({}); + const result = await blobClient.getProperties(); assert.deepStrictEqual(result.blobType, "BlockBlob"); assert.ok(result.lastModified); @@ -91,8 +90,8 @@ describe("BlobClient", () => { blobContentMD5: isNode ? Buffer.from([1, 2, 3, 4]) : new Uint8Array([1, 2, 3, 4]), blobContentType: "blobContentType" }; - await blobClient.setHTTPHeaders(Aborter.none, headers); - const result = await blobClient.getProperties(Aborter.none); + await blobClient.setHTTPHeaders(headers); + const result = await blobClient.getProperties(); assert.ok(result.date); assert.deepStrictEqual(result.blobType, "BlockBlob"); assert.ok(result.lastModified); @@ -108,113 +107,113 @@ describe("BlobClient", () => { it("acquireLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 30; - await blobClient.acquireLease(Aborter.none, guid, duration); + await blobClient.acquireLease(guid, duration); - const result = await blobClient.getProperties(Aborter.none); + const result = await blobClient.getProperties(); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await blobClient.releaseLease(Aborter.none, guid); + await blobClient.releaseLease(guid); }); it("releaseLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = -1; - await blobClient.acquireLease(Aborter.none, guid, duration); + await blobClient.acquireLease(guid, duration); - const result = await blobClient.getProperties(Aborter.none); + const result = await blobClient.getProperties(); assert.equal(result.leaseDuration, "infinite"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await blobClient.releaseLease(Aborter.none, guid); + await blobClient.releaseLease(guid); }); it("renewLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await blobClient.acquireLease(Aborter.none, guid, duration); + await blobClient.acquireLease(guid, duration); - const result = await blobClient.getProperties(Aborter.none); + const result = await blobClient.getProperties(); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); await sleep(20 * 1000); - const result2 = await blobClient.getProperties(Aborter.none); + const result2 = await blobClient.getProperties(); assert.ok(!result2.leaseDuration); assert.equal(result2.leaseState, "expired"); assert.equal(result2.leaseStatus, "unlocked"); - await blobClient.renewLease(Aborter.none, guid); - const result3 = await blobClient.getProperties(Aborter.none); + await blobClient.renewLease(guid); + const result3 = await blobClient.getProperties(); assert.equal(result3.leaseDuration, "fixed"); assert.equal(result3.leaseState, "leased"); assert.equal(result3.leaseStatus, "locked"); - await blobClient.releaseLease(Aborter.none, guid); + await blobClient.releaseLease(guid); }); it("changeLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await blobClient.acquireLease(Aborter.none, guid, duration); + await blobClient.acquireLease(guid, duration); - const result = await blobClient.getProperties(Aborter.none); + const result = await blobClient.getProperties(); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); const newGuid = "3c7e72ebb4304526bc53d8ecef03798f"; - await blobClient.changeLease(Aborter.none, guid, newGuid); + await blobClient.changeLease(guid, newGuid); - await blobClient.getProperties(Aborter.none); - await blobClient.releaseLease(Aborter.none, newGuid); + await blobClient.getProperties(); + await blobClient.releaseLease(newGuid); }); it("breakLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await blobClient.acquireLease(Aborter.none, guid, duration); + await blobClient.acquireLease(guid, duration); - const result = await blobClient.getProperties(Aborter.none); + const result = await blobClient.getProperties(); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await blobClient.breakLease(Aborter.none, 5); + await blobClient.breakLease(5); - const result2 = await blobClient.getProperties(Aborter.none); + const result2 = await blobClient.getProperties(); assert.ok(!result2.leaseDuration); assert.equal(result2.leaseState, "breaking"); assert.equal(result2.leaseStatus, "locked"); await sleep(5 * 1000); - const result3 = await blobClient.getProperties(Aborter.none); + const result3 = await blobClient.getProperties(); assert.ok(!result3.leaseDuration); assert.equal(result3.leaseState, "broken"); assert.equal(result3.leaseStatus, "unlocked"); }); it("delete", async () => { - await blobClient.delete(Aborter.none); + await blobClient.delete(); }); // The following code illustrates deleting a snapshot after creating one it("delete snapshot", async () => { - const result = await blobClient.createSnapshot(Aborter.none); + const result = await blobClient.createSnapshot(); assert.ok(result.snapshot); const blobSnapshotClient = blobClient.withSnapshot(result.snapshot!); - await blobSnapshotClient.getProperties(Aborter.none); + await blobSnapshotClient.getProperties(); - await blobSnapshotClient.delete(Aborter.none); - await blobClient.delete(Aborter.none); + await blobSnapshotClient.delete(); + await blobClient.delete(); - const result2 = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + const result2 = await containerClient.listBlobFlatSegment(undefined, { include: ["snapshots"] }); @@ -223,13 +222,13 @@ describe("BlobClient", () => { }); it("createSnapshot", async () => { - const result = await blobClient.createSnapshot(Aborter.none); + const result = await blobClient.createSnapshot(); assert.ok(result.snapshot); const blobSnapshotClient = blobClient.withSnapshot(result.snapshot!); - await blobSnapshotClient.getProperties(Aborter.none); + await blobSnapshotClient.getProperties(); - const result3 = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + const result3 = await containerClient.listBlobFlatSegment(undefined, { include: ["snapshots"] }); @@ -252,9 +251,9 @@ describe("BlobClient", () => { }); it("undelete", async () => { - const properties = await blobServiceClient.getProperties(Aborter.none); + const properties = await blobServiceClient.getProperties(); if (!properties.deleteRetentionPolicy!.enabled) { - await blobServiceClient.setProperties(Aborter.none, { + await blobServiceClient.setProperties({ deleteRetentionPolicy: { days: 7, enabled: true @@ -263,15 +262,15 @@ describe("BlobClient", () => { await sleep(15 * 1000); } - await blobClient.delete(Aborter.none); + await blobClient.delete(); - const result = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + const result = await containerClient.listBlobFlatSegment(undefined, { include: ["deleted"] }); assert.ok(result.segment.blobItems![0].deleted); - await blobClient.undelete(Aborter.none); - const result2 = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blobClient.undelete(); + const result2 = await containerClient.listBlobFlatSegment(undefined, { include: ["deleted"] }); assert.ok(!result2.segment.blobItems![0].deleted); @@ -282,11 +281,11 @@ describe("BlobClient", () => { containerClient, getUniqueName("copiedblob") ); - const result = await newBlobClient.startCopyFromURL(Aborter.none, blobClient.url); + const result = await newBlobClient.startCopyFromURL(blobClient.url); assert.ok(result.copyId); - const properties1 = await blobClient.getProperties(Aborter.none); - const properties2 = await newBlobClient.getProperties(Aborter.none); + const properties1 = await blobClient.getProperties(); + const properties2 = await newBlobClient.getProperties(); assert.deepStrictEqual(properties1.contentMD5, properties2.contentMD5); assert.deepStrictEqual(properties2.copyId, result.copyId); assert.deepStrictEqual(properties2.copySource, blobClient.url); @@ -297,12 +296,12 @@ describe("BlobClient", () => { containerClient, getUniqueName("copiedblob") ); - const result = await newBlobClient.startCopyFromURL(Aborter.none, blobClient.url); + const result = await newBlobClient.startCopyFromURL(blobClient.url); assert.ok(result.copyId); sleep(1 * 1000); try { - await newBlobClient.startCopyFromURL(Aborter.none, result.copyId!); + await newBlobClient.startCopyFromURL(result.copyId!); assert.fail( "AbortCopyFromClient should be failed and throw exception for an completed copy operation." ); @@ -312,18 +311,18 @@ describe("BlobClient", () => { }); it("setTier set default to cool", async () => { - await blockBlobClient.setTier(Aborter.none, "Cool"); - const properties = await blockBlobClient.getProperties(Aborter.none); + await blockBlobClient.setTier("Cool"); + const properties = await blockBlobClient.getProperties(); assert.equal(properties.accessTier!.toLowerCase(), "cool"); }); it("setTier set archive to hot", async () => { - await blockBlobClient.setTier(Aborter.none, "Archive"); - let properties = await blockBlobClient.getProperties(Aborter.none); + await blockBlobClient.setTier("Archive"); + let properties = await blockBlobClient.getProperties(); assert.equal(properties.accessTier!.toLowerCase(), "archive"); - await blockBlobClient.setTier(Aborter.none, "Hot"); - properties = await blockBlobClient.getProperties(Aborter.none); + await blockBlobClient.setTier("Hot"); + properties = await blockBlobClient.getProperties(); if (properties.archiveStatus) { assert.equal(properties.archiveStatus.toLowerCase(), "rehydrate-pending-to-hot"); } diff --git a/sdk/storage/storage-blob/test/blobserviceclient.spec.ts b/sdk/storage/storage-blob/test/blobserviceclient.spec.ts index 5ccc92306506..6aa3e7653bc3 100644 --- a/sdk/storage/storage-blob/test/blobserviceclient.spec.ts +++ b/sdk/storage/storage-blob/test/blobserviceclient.spec.ts @@ -1,6 +1,5 @@ import * as assert from "assert"; -import { Aborter } from "../src/Aborter"; import { ContainerClient } from "../src/ContainerClient"; import { BlobServiceClient } from "../src/BlobServiceClient"; import { getAlternateBSU, getBSU, getUniqueName, wait } from "./utils"; @@ -10,7 +9,7 @@ dotenv.config({ path: "../.env" }); describe("BlobServiceClient", () => { it("ListContainers with default parameters", async () => { const blobServiceClient = getBSU(); - const result = await blobServiceClient.listContainersSegment(Aborter.none); + const result = await blobServiceClient.listContainersSegment(); assert.ok(typeof result.requestId); assert.ok(result.requestId!.length > 0); assert.ok(typeof result.version); @@ -35,10 +34,10 @@ describe("BlobServiceClient", () => { const containerName2 = `${containerNamePrefix}x2`; const containerClient1 = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName1); const containerClient2 = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName2); - await containerClient1.create(Aborter.none, { metadata: { key: "val" } }); - await containerClient2.create(Aborter.none, { metadata: { key: "val" } }); + await containerClient1.create({ metadata: { key: "val" } }); + await containerClient2.create({ metadata: { key: "val" } }); - const result1 = await blobServiceClient.listContainersSegment(Aborter.none, undefined, { + const result1 = await blobServiceClient.listContainersSegment(undefined, { include: "metadata", maxresults: 1, prefix: containerNamePrefix @@ -55,7 +54,7 @@ describe("BlobServiceClient", () => { assert.deepEqual(result1.containerItems![0].properties.leaseStatus, "unlocked"); assert.deepEqual(result1.containerItems![0].metadata!.key, "val"); - const result2 = await blobServiceClient.listContainersSegment(Aborter.none, result1.nextMarker, { + const result2 = await blobServiceClient.listContainersSegment(result1.nextMarker, { include: "metadata", maxresults: 1, prefix: containerNamePrefix @@ -72,13 +71,13 @@ describe("BlobServiceClient", () => { assert.deepEqual(result2.containerItems![0].properties.leaseStatus, "unlocked"); assert.deepEqual(result2.containerItems![0].metadata!.key, "val"); - await containerClient1.delete(Aborter.none); - await containerClient2.delete(Aborter.none); + await containerClient1.delete(); + await containerClient2.delete(); }); it("GetProperties", async () => { const blobServiceClient = getBSU(); - const result = await blobServiceClient.getProperties(Aborter.none); + const result = await blobServiceClient.getProperties(); assert.ok(typeof result.requestId); assert.ok(result.requestId!.length > 0); @@ -97,7 +96,7 @@ describe("BlobServiceClient", () => { it("SetProperties", async () => { const blobServiceClient = getBSU(); - const serviceProperties = await blobServiceClient.getProperties(Aborter.none); + const serviceProperties = await blobServiceClient.getProperties(); serviceProperties.logging = { deleteProperty: true, @@ -150,10 +149,10 @@ describe("BlobServiceClient", () => { }; } - await blobServiceClient.setProperties(Aborter.none, serviceProperties); + await blobServiceClient.setProperties(serviceProperties); await wait(5 * 1000); - const result = await blobServiceClient.getProperties(Aborter.none); + const result = await blobServiceClient.getProperties(); assert.ok(typeof result.requestId); assert.ok(result.requestId!.length > 0); assert.ok(typeof result.version); @@ -171,7 +170,7 @@ describe("BlobServiceClient", () => { } blobServiceClient! - .getStatistics(Aborter.none) + .getStatistics() .then((result) => { assert.ok(result.geoReplication!.lastSyncTime); done(); @@ -182,7 +181,7 @@ describe("BlobServiceClient", () => { it("getAccountInfo", async () => { const blobServiceClient = getBSU(); - const accountInfo = await blobServiceClient.getAccountInfo(Aborter.none); + const accountInfo = await blobServiceClient.getAccountInfo(); assert.ok(accountInfo.accountKind); assert.ok(accountInfo.skuName); }); diff --git a/sdk/storage/storage-blob/test/blockblobclient.spec.ts b/sdk/storage/storage-blob/test/blockblobclient.spec.ts index 3f931b3fd53f..f4909d7b0ae3 100644 --- a/sdk/storage/storage-blob/test/blockblobclient.spec.ts +++ b/sdk/storage/storage-blob/test/blockblobclient.spec.ts @@ -1,6 +1,5 @@ import * as assert from "assert"; -import { Aborter } from "../src/Aborter"; import { BlobClient } from "../src/BlobClient"; import { BlockBlobClient } from "../src/BlockBlobClient"; import { ContainerClient } from "../src/ContainerClient"; @@ -19,20 +18,20 @@ describe("BlockBlobClient", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); blobName = getUniqueName("blob"); blobClient = BlobClient.fromContainerClient(containerClient, blobName); blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("upload with string body and default parameters", async () => { const body: string = getUniqueName("randomstring"); - await blockBlobClient.upload(Aborter.none, body, body.length); - const result = await blobClient.download(Aborter.none, 0); + await blockBlobClient.upload(body, body.length); + const result = await blobClient.download(0); assert.deepStrictEqual(await bodyToString(result, body.length), body); }); @@ -49,11 +48,11 @@ describe("BlockBlobClient", () => { keyb: "valb" } }; - await blockBlobClient.upload(Aborter.none, body, body.length, { + await blockBlobClient.upload(body, body.length, { blobHTTPHeaders: options, metadata: options.metadata }); - const result = await blobClient.download(Aborter.none, 0); + const result = await blobClient.download(0); assert.deepStrictEqual(await bodyToString(result, body.length), body); assert.deepStrictEqual(result.cacheControl, options.blobCacheControl); assert.deepStrictEqual(result.contentDisposition, options.blobContentDisposition); @@ -65,9 +64,9 @@ describe("BlockBlobClient", () => { it("stageBlock", async () => { const body = "HelloWorld"; - await blockBlobClient.stageBlock(Aborter.none, base64encode("1"), body, body.length); - await blockBlobClient.stageBlock(Aborter.none, base64encode("2"), body, body.length); - const listResponse = await blockBlobClient.getBlockList(Aborter.none, "uncommitted"); + await blockBlobClient.stageBlock(base64encode("1"), body, body.length); + await blockBlobClient.stageBlock(base64encode("2"), body, body.length); + const listResponse = await blockBlobClient.getBlockList("uncommitted"); assert.equal(listResponse.uncommittedBlocks!.length, 2); assert.equal(listResponse.uncommittedBlocks![0].name, base64encode("1")); assert.equal(listResponse.uncommittedBlocks![0].size, body.length); @@ -77,12 +76,12 @@ describe("BlockBlobClient", () => { it("stageBlockFromURL copy source blob as single block", async () => { const body = "HelloWorld"; - await blockBlobClient.upload(Aborter.none, body, body.length); + await blockBlobClient.upload(body, body.length); // When testing is in Node.js environment with shared key, setAccessPolicy will work // But in browsers testing with SAS tokens, below will throw an exception, ignore it try { - await containerClient.setAccessPolicy(Aborter.none, "container"); + await containerClient.setAccessPolicy("container"); // tslint:disable-next-line:no-empty } catch (err) {} @@ -91,13 +90,12 @@ describe("BlockBlobClient", () => { getUniqueName("newblockblob") ); await newBlockBlobClient.stageBlockFromURL( - Aborter.none, base64encode("1"), blockBlobClient.url, 0 ); - const listResponse = await newBlockBlobClient.getBlockList(Aborter.none, "uncommitted"); + const listResponse = await newBlockBlobClient.getBlockList("uncommitted"); assert.equal(listResponse.uncommittedBlocks!.length, 1); assert.equal(listResponse.uncommittedBlocks![0].name, base64encode("1")); assert.equal(listResponse.uncommittedBlocks![0].size, body.length); @@ -105,12 +103,12 @@ describe("BlockBlobClient", () => { it("stageBlockFromURL copy source blob as separate blocks", async () => { const body = "HelloWorld"; - await blockBlobClient.upload(Aborter.none, body, body.length); + await blockBlobClient.upload(body, body.length); // When testing is in Node.js environment with shared key, setAccessPolicy will work // But in browsers testing with SAS tokens, below will throw an exception, ignore it try { - await containerClient.setAccessPolicy(Aborter.none, "container"); + await containerClient.setAccessPolicy("container"); // tslint:disable-next-line:no-empty } catch (err) {} @@ -119,28 +117,25 @@ describe("BlockBlobClient", () => { getUniqueName("newblockblob") ); await newBlockBlobClient.stageBlockFromURL( - Aborter.none, base64encode("1"), blockBlobClient.url, 0, 4 ); await newBlockBlobClient.stageBlockFromURL( - Aborter.none, base64encode("2"), blockBlobClient.url, 4, 4 ); await newBlockBlobClient.stageBlockFromURL( - Aborter.none, base64encode("3"), blockBlobClient.url, 8, 2 ); - const listResponse = await newBlockBlobClient.getBlockList(Aborter.none, "uncommitted"); + const listResponse = await newBlockBlobClient.getBlockList("uncommitted"); assert.equal(listResponse.uncommittedBlocks!.length, 3); assert.equal(listResponse.uncommittedBlocks![0].name, base64encode("1")); assert.equal(listResponse.uncommittedBlocks![0].size, 4); @@ -149,22 +144,22 @@ describe("BlockBlobClient", () => { assert.equal(listResponse.uncommittedBlocks![2].name, base64encode("3")); assert.equal(listResponse.uncommittedBlocks![2].size, 2); - await newBlockBlobClient.commitBlockList(Aborter.none, [ + await newBlockBlobClient.commitBlockList([ base64encode("1"), base64encode("2"), base64encode("3") ]); - const downloadResponse = await newBlockBlobClient.download(Aborter.none, 0); + const downloadResponse = await newBlockBlobClient.download(0); assert.equal(await bodyToString(downloadResponse, 10), body); }); it("commitBlockList", async () => { const body = "HelloWorld"; - await blockBlobClient.stageBlock(Aborter.none, base64encode("1"), body, body.length); - await blockBlobClient.stageBlock(Aborter.none, base64encode("2"), body, body.length); - await blockBlobClient.commitBlockList(Aborter.none, [base64encode("1"), base64encode("2")]); - const listResponse = await blockBlobClient.getBlockList(Aborter.none, "committed"); + await blockBlobClient.stageBlock(base64encode("1"), body, body.length); + await blockBlobClient.stageBlock(base64encode("2"), body, body.length); + await blockBlobClient.commitBlockList([base64encode("1"), base64encode("2")]); + const listResponse = await blockBlobClient.getBlockList("committed"); assert.equal(listResponse.committedBlocks!.length, 2); assert.equal(listResponse.committedBlocks![0].name, base64encode("1")); assert.equal(listResponse.committedBlocks![0].size, body.length); @@ -174,8 +169,8 @@ describe("BlockBlobClient", () => { it("commitBlockList with all parameters set", async () => { const body = "HelloWorld"; - await blockBlobClient.stageBlock(Aborter.none, base64encode("1"), body, body.length); - await blockBlobClient.stageBlock(Aborter.none, base64encode("2"), body, body.length); + await blockBlobClient.stageBlock(base64encode("1"), body, body.length); + await blockBlobClient.stageBlock(base64encode("2"), body, body.length); const options = { blobCacheControl: "blobCacheControl", @@ -188,19 +183,19 @@ describe("BlockBlobClient", () => { keyb: "valb" } }; - await blockBlobClient.commitBlockList(Aborter.none, [base64encode("1"), base64encode("2")], { + await blockBlobClient.commitBlockList([base64encode("1"), base64encode("2")], { blobHTTPHeaders: options, metadata: options.metadata }); - const listResponse = await blockBlobClient.getBlockList(Aborter.none, "committed"); + const listResponse = await blockBlobClient.getBlockList("committed"); assert.equal(listResponse.committedBlocks!.length, 2); assert.equal(listResponse.committedBlocks![0].name, base64encode("1")); assert.equal(listResponse.committedBlocks![0].size, body.length); assert.equal(listResponse.committedBlocks![1].name, base64encode("2")); assert.equal(listResponse.committedBlocks![1].size, body.length); - const result = await blobClient.download(Aborter.none, 0); + const result = await blobClient.download(0); assert.deepStrictEqual(await bodyToString(result, body.repeat(2).length), body.repeat(2)); assert.deepStrictEqual(result.cacheControl, options.blobCacheControl); assert.deepStrictEqual(result.contentDisposition, options.blobContentDisposition); @@ -212,10 +207,10 @@ describe("BlockBlobClient", () => { it("getBlockList", async () => { const body = "HelloWorld"; - await blockBlobClient.stageBlock(Aborter.none, base64encode("1"), body, body.length); - await blockBlobClient.stageBlock(Aborter.none, base64encode("2"), body, body.length); - await blockBlobClient.commitBlockList(Aborter.none, [base64encode("2")]); - const listResponse = await blockBlobClient.getBlockList(Aborter.none, "all"); + await blockBlobClient.stageBlock(base64encode("1"), body, body.length); + await blockBlobClient.stageBlock(base64encode("2"), body, body.length); + await blockBlobClient.commitBlockList([base64encode("2")]); + const listResponse = await blockBlobClient.getBlockList("all"); assert.equal(listResponse.committedBlocks!.length, 1); assert.equal(listResponse.uncommittedBlocks!.length, 0); assert.equal(listResponse.committedBlocks![0].name, base64encode("2")); diff --git a/sdk/storage/storage-blob/test/browser/highlevel.browser.spec.ts b/sdk/storage/storage-blob/test/browser/highlevel.browser.spec.ts index ec3f5a3bc826..cb3c85e34fff 100644 --- a/sdk/storage/storage-blob/test/browser/highlevel.browser.spec.ts +++ b/sdk/storage/storage-blob/test/browser/highlevel.browser.spec.ts @@ -32,14 +32,14 @@ describe("Highelvel", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(serviceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); blobName = getUniqueName("blob"); blobClient = BlobClient.fromContainerClient(containerClient, blobName); blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); before(async () => { @@ -53,7 +53,9 @@ describe("Highelvel", () => { const aborter = Aborter.timeout(1); try { - await uploadBrowserDataToBlockBlob(aborter, tempFile1, blockBlobClient); + await uploadBrowserDataToBlockBlob(tempFile1, blockBlobClient, { + abortSignal: aborter + }); assert.fail(); } catch (err) { assert.ok((err.code as string).toLowerCase().includes("abort")); @@ -64,7 +66,8 @@ describe("Highelvel", () => { const aborter = Aborter.timeout(1); try { - await uploadBrowserDataToBlockBlob(aborter, tempFile2, blockBlobClient, { + await uploadBrowserDataToBlockBlob(tempFile2, blockBlobClient, { + abortSignal: aborter, blockSize: 4 * 1024 * 1024, parallelism: 2 }); @@ -79,7 +82,8 @@ describe("Highelvel", () => { const aborter = Aborter.none; try { - await uploadBrowserDataToBlockBlob(aborter, tempFile1, blockBlobClient, { + await uploadBrowserDataToBlockBlob(tempFile1, blockBlobClient, { + abortSignal: aborter, blockSize: 4 * 1024 * 1024, parallelism: 2, progress: (ev) => { @@ -97,7 +101,8 @@ describe("Highelvel", () => { const aborter = Aborter.none; try { - await uploadBrowserDataToBlockBlob(aborter, tempFile2, blockBlobClient, { + await uploadBrowserDataToBlockBlob(tempFile2, blockBlobClient, { + abortSignal: aborter, blockSize: 4 * 1024 * 1024, parallelism: 2, progress: (ev) => { @@ -111,12 +116,12 @@ describe("Highelvel", () => { }); it("uploadBrowserDataToBlockBlob should success when blob < BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES", async () => { - await uploadBrowserDataToBlockBlob(Aborter.none, tempFile2, blockBlobClient, { + await uploadBrowserDataToBlockBlob(tempFile2, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 2 }); - const downloadResponse = await blockBlobClient.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(0); const downloadedString = await bodyToString(downloadResponse); const uploadedString = await blobToString(tempFile2); @@ -124,12 +129,12 @@ describe("Highelvel", () => { }); it("uploadBrowserDataToBlockBlob should success when blob < BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES and configured maxSingleShotSize", async () => { - await uploadBrowserDataToBlockBlob(Aborter.none, tempFile2, blockBlobClient, { + await uploadBrowserDataToBlockBlob(tempFile2, blockBlobClient, { blockSize: 512 * 1024, maxSingleShotSize: 0 }); - const downloadResponse = await blockBlobClient.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(0); const downloadedString = await bodyToString(downloadResponse); const uploadedString = await blobToString(tempFile2); @@ -145,12 +150,12 @@ describe("Highelvel", () => { return; } - await uploadBrowserDataToBlockBlob(Aborter.none, tempFile1, blockBlobClient, { + await uploadBrowserDataToBlockBlob(tempFile1, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 2 }); - const downloadResponse = await blockBlobClient.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(0); const buf1 = await blobToArrayBuffer(await downloadResponse.blobBody!); const buf2 = await blobToArrayBuffer(tempFile1); diff --git a/sdk/storage/storage-blob/test/containerclient.spec.ts b/sdk/storage/storage-blob/test/containerclient.spec.ts index 2aacdb4f1c8d..0fa6ba49b5b8 100644 --- a/sdk/storage/storage-blob/test/containerclient.spec.ts +++ b/sdk/storage/storage-blob/test/containerclient.spec.ts @@ -1,6 +1,5 @@ import * as assert from "assert"; -import { Aborter } from "../src/Aborter"; import { BlobClient } from "../src/BlobClient"; import { BlockBlobClient } from "../src/BlockBlobClient"; import { ContainerClient } from "../src/ContainerClient"; @@ -16,11 +15,11 @@ describe("ContainerClient", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("setMetadata", async () => { @@ -29,14 +28,14 @@ describe("ContainerClient", () => { keya: "vala", keyb: "valb" }; - await containerClient.setMetadata(Aborter.none, metadata); + await containerClient.setMetadata(metadata); - const result = await containerClient.getProperties(Aborter.none); + const result = await containerClient.getProperties(); assert.deepEqual(result.metadata, metadata); }); it("getProperties", async () => { - const result = await containerClient.getProperties(Aborter.none); + const result = await containerClient.getProperties(); assert.ok(result.eTag!.length > 0); assert.ok(result.lastModified); assert.ok(!result.leaseDuration); @@ -57,8 +56,8 @@ describe("ContainerClient", () => { const cClient = ContainerClient.fromBlobServiceClient(blobServiceClient, getUniqueName(containerName)); const metadata = { key: "value" }; const access = "container"; - await cClient.create(Aborter.none, { metadata, access }); - const result = await cClient.getProperties(Aborter.none); + await cClient.create({ metadata, access }); + const result = await cClient.getProperties(); assert.deepEqual(result.blobPublicAccess, access); assert.deepEqual(result.metadata, metadata); }); @@ -71,91 +70,91 @@ describe("ContainerClient", () => { it("acquireLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 30; - await containerClient.acquireLease(Aborter.none, guid, duration); + await containerClient.acquireLease(guid, duration); - const result = await containerClient.getProperties(Aborter.none); + const result = await containerClient.getProperties(); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await containerClient.releaseLease(Aborter.none, guid); + await containerClient.releaseLease(guid); }); it("releaseLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = -1; - await containerClient.acquireLease(Aborter.none, guid, duration); + await containerClient.acquireLease(guid, duration); - const result = await containerClient.getProperties(Aborter.none); + const result = await containerClient.getProperties(); assert.equal(result.leaseDuration, "infinite"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await containerClient.releaseLease(Aborter.none, guid); + await containerClient.releaseLease(guid); }); it("renewLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await containerClient.acquireLease(Aborter.none, guid, duration); + await containerClient.acquireLease(guid, duration); - const result = await containerClient.getProperties(Aborter.none); + const result = await containerClient.getProperties(); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); await sleep(16 * 1000); - const result2 = await containerClient.getProperties(Aborter.none); + const result2 = await containerClient.getProperties(); assert.ok(!result2.leaseDuration); assert.equal(result2.leaseState, "expired"); assert.equal(result2.leaseStatus, "unlocked"); - await containerClient.renewLease(Aborter.none, guid); - const result3 = await containerClient.getProperties(Aborter.none); + await containerClient.renewLease(guid); + const result3 = await containerClient.getProperties(); assert.equal(result3.leaseDuration, "fixed"); assert.equal(result3.leaseState, "leased"); assert.equal(result3.leaseStatus, "locked"); - await containerClient.releaseLease(Aborter.none, guid); + await containerClient.releaseLease(guid); }); it("changeLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await containerClient.acquireLease(Aborter.none, guid, duration); + await containerClient.acquireLease(guid, duration); - const result = await containerClient.getProperties(Aborter.none); + const result = await containerClient.getProperties(); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); const newGuid = "3c7e72ebb4304526bc53d8ecef03798f"; - await containerClient.changeLease(Aborter.none, guid, newGuid); + await containerClient.changeLease(guid, newGuid); - await containerClient.getProperties(Aborter.none); - await containerClient.releaseLease(Aborter.none, newGuid); + await containerClient.getProperties(); + await containerClient.releaseLease(newGuid); }); it("breakLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await containerClient.acquireLease(Aborter.none, guid, duration); + await containerClient.acquireLease(guid, duration); - const result = await containerClient.getProperties(Aborter.none); + const result = await containerClient.getProperties(); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await containerClient.breakLease(Aborter.none, 3); + await containerClient.breakLease(3); - const result2 = await containerClient.getProperties(Aborter.none); + const result2 = await containerClient.getProperties(); assert.ok(!result2.leaseDuration); assert.equal(result2.leaseState, "breaking"); assert.equal(result2.leaseStatus, "locked"); await sleep(3 * 1000); - const result3 = await containerClient.getProperties(Aborter.none); + const result3 = await containerClient.getProperties(); assert.ok(!result3.leaseDuration); assert.equal(result3.leaseState, "broken"); assert.equal(result3.leaseStatus, "unlocked"); @@ -169,11 +168,11 @@ describe("ContainerClient", () => { getUniqueName(`blockblob/${i}`) ); const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); - await blockBlobClient.upload(Aborter.none, "", 0); + await blockBlobClient.upload("", 0); blobClients.push(blobClient); } - const result = await containerClient.listBlobFlatSegment(Aborter.none); + const result = await containerClient.listBlobFlatSegment(); assert.ok(result.serviceEndpoint.length > 0); assert.ok(containerClient.url.indexOf(result.containerName)); assert.deepStrictEqual(result.nextMarker, ""); @@ -181,7 +180,7 @@ describe("ContainerClient", () => { assert.ok(blobClients[0].url.indexOf(result.segment.blobItems![0].name)); for (const blob of blobClients) { - await blob.delete(Aborter.none); + await blob.delete(); } }); @@ -198,13 +197,13 @@ describe("ContainerClient", () => { getUniqueName(`${prefix}/${i}`) ); const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); - await blockBlobClient.upload(Aborter.none, "", 0, { + await blockBlobClient.upload("", 0, { metadata }); blobClients.push(blobClient); } - const result = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + const result = await containerClient.listBlobFlatSegment(undefined, { include: ["snapshots", "metadata", "uncommittedblobs", "copy", "deleted"], maxresults: 1, prefix @@ -215,7 +214,7 @@ describe("ContainerClient", () => { assert.ok(blobClients[0].url.indexOf(result.segment.blobItems![0].name)); assert.deepStrictEqual(result.segment.blobItems![0].metadata, metadata); - const result2 = await containerClient.listBlobFlatSegment(Aborter.none, result.nextMarker, { + const result2 = await containerClient.listBlobFlatSegment(result.nextMarker, { include: ["snapshots", "metadata", "uncommittedblobs", "copy", "deleted"], maxresults: 2, prefix @@ -228,7 +227,7 @@ describe("ContainerClient", () => { assert.deepStrictEqual(result2.segment.blobItems![0].metadata, metadata); for (const blob of blobClients) { - await blob.delete(Aborter.none); + await blob.delete(); } }); @@ -240,12 +239,12 @@ describe("ContainerClient", () => { getUniqueName(`blockblob${i}/${i}`) ); const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); - await blockBlobClient.upload(Aborter.none, "", 0); + await blockBlobClient.upload("", 0); blobClients.push(blobClient); } const delimiter = "/"; - const result = await containerClient.listBlobHierarchySegment(Aborter.none, delimiter); + const result = await containerClient.listBlobHierarchySegment(delimiter); assert.ok(result.serviceEndpoint.length > 0); assert.ok(containerClient.url.indexOf(result.containerName)); assert.deepStrictEqual(result.nextMarker, ""); @@ -258,7 +257,7 @@ describe("ContainerClient", () => { } for (const blob of blobClients) { - await blob.delete(Aborter.none); + await blob.delete(); } }); @@ -276,14 +275,13 @@ describe("ContainerClient", () => { getUniqueName(`${prefix}${i}${delimiter}${i}`) ); const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); - await blockBlobClient.upload(Aborter.none, "", 0, { + await blockBlobClient.upload("", 0, { metadata }); blobClients.push(blobClient); } const result = await containerClient.listBlobHierarchySegment( - Aborter.none, delimiter, undefined, { @@ -299,7 +297,6 @@ describe("ContainerClient", () => { assert.ok(blobClients[0].url.indexOf(result.segment.blobPrefixes![0].name)); const result2 = await containerClient.listBlobHierarchySegment( - Aborter.none, delimiter, result.nextMarker, { @@ -315,7 +312,6 @@ describe("ContainerClient", () => { assert.ok(blobClients[0].url.indexOf(result2.segment.blobPrefixes![0].name)); const result3 = await containerClient.listBlobHierarchySegment( - Aborter.none, delimiter, undefined, { @@ -333,7 +329,7 @@ describe("ContainerClient", () => { assert.ok(blobClients[0].url.indexOf(result3.segment.blobItems![0].name)); for (const blob of blobClients) { - await blob.delete(Aborter.none); + await blob.delete(); } }); }); diff --git a/sdk/storage/storage-blob/test/node/blockblobclient.spec.ts b/sdk/storage/storage-blob/test/node/blockblobclient.spec.ts index 7d787c5da71c..788aaed4890b 100644 --- a/sdk/storage/storage-blob/test/node/blockblobclient.spec.ts +++ b/sdk/storage/storage-blob/test/node/blockblobclient.spec.ts @@ -1,6 +1,5 @@ import * as assert from "assert"; -import { Aborter } from "../../src/Aborter"; import { BlobClient } from "../../src/BlobClient"; import { BlockBlobClient } from "../../src/BlockBlobClient"; import { ContainerClient } from "../../src/ContainerClient"; @@ -17,22 +16,22 @@ describe("BlockBlobClient Node.js only", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); blobName = getUniqueName("blob"); blobClient = BlobClient.fromContainerClient(containerClient, blobName); blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("upload with Readable stream body and default parameters", async () => { const body: string = getUniqueName("randomstring"); const bodyBuffer = Buffer.from(body); - await blockBlobClient.upload(Aborter.none, bodyBuffer, body.length); - const result = await blobClient.download(Aborter.none, 0); + await blockBlobClient.upload(bodyBuffer, body.length); + const result = await blobClient.download(0); const downloadedBody = await new Promise((resolve, reject) => { const buffer: string[] = []; @@ -50,8 +49,8 @@ describe("BlockBlobClient Node.js only", () => { it("upload with Chinese string body and default parameters", async () => { const body: string = getUniqueName("randomstring你好"); - await blockBlobClient.upload(Aborter.none, body, Buffer.byteLength(body)); - const result = await blobClient.download(Aborter.none, 0); + await blockBlobClient.upload(body, Buffer.byteLength(body)); + const result = await blobClient.download(0); assert.deepStrictEqual(await bodyToString(result, Buffer.byteLength(body)), body); }); }); diff --git a/sdk/storage/storage-blob/test/node/containerclient.spec.ts b/sdk/storage/storage-blob/test/node/containerclient.spec.ts index af9c298d160d..18e118ba6ff8 100644 --- a/sdk/storage/storage-blob/test/node/containerclient.spec.ts +++ b/sdk/storage/storage-blob/test/node/containerclient.spec.ts @@ -1,6 +1,5 @@ import * as assert from "assert"; -import { Aborter } from "../../src/Aborter"; import { ContainerClient } from "../../src/ContainerClient"; import { getBSU, getUniqueName } from "../utils"; import { PublicAccessType } from "../../src/generated/lib/models/index"; @@ -13,15 +12,15 @@ describe("ContainerClient", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("getAccessPolicy", async () => { - const result = await containerClient.getAccessPolicy(Aborter.none); + const result = await containerClient.getAccessPolicy(); assert.ok(result.eTag!.length > 0); assert.ok(result.lastModified); assert.ok(result.requestId); @@ -42,8 +41,8 @@ describe("ContainerClient", () => { } ]; - await containerClient.setAccessPolicy(Aborter.none, access, containerAcl); - const result = await containerClient.getAccessPolicy(Aborter.none); + await containerClient.setAccessPolicy(access, containerAcl); + const result = await containerClient.getAccessPolicy(); assert.deepEqual(result.signedIdentifiers, containerAcl); assert.deepEqual(result.blobPublicAccess, access); }); diff --git a/sdk/storage/storage-blob/test/node/highlevel.node.spec.ts b/sdk/storage/storage-blob/test/node/highlevel.node.spec.ts index 7c23acf989ca..0f397306797d 100644 --- a/sdk/storage/storage-blob/test/node/highlevel.node.spec.ts +++ b/sdk/storage/storage-blob/test/node/highlevel.node.spec.ts @@ -30,14 +30,14 @@ describe("Highlevel", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); blobName = getUniqueName("blob"); blobClient = BlobClient.fromContainerClient(containerClient, blobName); blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); before(async () => { @@ -56,12 +56,12 @@ describe("Highlevel", () => { }); it("uploadFileToBlockBlob should success when blob >= BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES", async () => { - await uploadFileToBlockBlob(Aborter.none, tempFileLarge, blockBlobClient, { + await uploadFileToBlockBlob(tempFileLarge, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 20 }); - const downloadResponse = await blockBlobClient.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(0); const downloadedFile = path.join(tempFolderPath, getUniqueName("downloadfile.")); await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadedFile); @@ -73,12 +73,12 @@ describe("Highlevel", () => { }); it("uploadFileToBlockBlob should success when blob < BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES", async () => { - await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobClient, { + await uploadFileToBlockBlob(tempFileSmall, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 20 }); - const downloadResponse = await blockBlobClient.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(0); const downloadedFile = path.join(tempFolderPath, getUniqueName("downloadfile.")); await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadedFile); @@ -90,11 +90,11 @@ describe("Highlevel", () => { }); it("uploadFileToBlockBlob should success when blob < BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES and configured maxSingleShotSize", async () => { - await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobClient, { + await uploadFileToBlockBlob(tempFileSmall, blockBlobClient, { maxSingleShotSize: 0 }); - const downloadResponse = await blockBlobClient.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(0); const downloadedFile = path.join(tempFolderPath, getUniqueName("downloadfile.")); await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadedFile); @@ -109,7 +109,8 @@ describe("Highlevel", () => { const aborter = Aborter.timeout(1); try { - await uploadFileToBlockBlob(aborter, tempFileLarge, blockBlobClient, { + await uploadFileToBlockBlob(tempFileLarge, blockBlobClient, { + abortSignal: aborter, blockSize: 4 * 1024 * 1024, parallelism: 20 }); @@ -123,7 +124,8 @@ describe("Highlevel", () => { const aborter = Aborter.timeout(1); try { - await uploadFileToBlockBlob(aborter, tempFileSmall, blockBlobClient, { + await uploadFileToBlockBlob(tempFileSmall, blockBlobClient, { + abortSignal: aborter, blockSize: 4 * 1024 * 1024, parallelism: 20 }); @@ -138,7 +140,8 @@ describe("Highlevel", () => { const aborter = Aborter.none; try { - await uploadFileToBlockBlob(aborter, tempFileLarge, blockBlobClient, { + await uploadFileToBlockBlob(tempFileLarge, blockBlobClient, { + abortSignal: aborter, blockSize: 4 * 1024 * 1024, parallelism: 20, progress: (ev) => { @@ -156,7 +159,8 @@ describe("Highlevel", () => { const aborter = Aborter.none; try { - await uploadFileToBlockBlob(aborter, tempFileSmall, blockBlobClient, { + await uploadFileToBlockBlob(tempFileSmall, blockBlobClient, { + abortSignal: aborter, blockSize: 4 * 1024 * 1024, parallelism: 20, progress: (ev) => { @@ -171,9 +175,9 @@ describe("Highlevel", () => { it("uploadStreamToBlockBlob should success", async () => { const rs = fs.createReadStream(tempFileLarge); - await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobClient, 4 * 1024 * 1024, 20); + await uploadStreamToBlockBlob(rs, blockBlobClient, 4 * 1024 * 1024, 20); - const downloadResponse = await blockBlobClient.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(0); const downloadFilePath = path.join(tempFolderPath, getUniqueName("downloadFile")); await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadFilePath); @@ -190,9 +194,9 @@ describe("Highlevel", () => { const bufferStream = new PassThrough(); bufferStream.end(buf); - await uploadStreamToBlockBlob(Aborter.none, bufferStream, blockBlobClient, 4 * 1024 * 1024, 20); + await uploadStreamToBlockBlob(bufferStream, blockBlobClient, 4 * 1024 * 1024, 20); - const downloadResponse = await blockBlobClient.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(0); const downloadFilePath = path.join(tempFolderPath, getUniqueName("downloadFile")); await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadFilePath); @@ -208,7 +212,15 @@ describe("Highlevel", () => { const aborter = Aborter.timeout(1); try { - await uploadStreamToBlockBlob(aborter, rs, blockBlobClient, 4 * 1024 * 1024, 20); + await uploadStreamToBlockBlob( + rs, + blockBlobClient, + 4 * 1024 * 1024, + 20, + { + abortSignal: aborter + } + ); assert.fail(); } catch (err) { assert.ok((err.code as string).toLowerCase().includes("abort")); @@ -219,7 +231,7 @@ describe("Highlevel", () => { const rs = fs.createReadStream(tempFileLarge); let eventTriggered = false; - await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobClient, 4 * 1024 * 1024, 20, { + await uploadStreamToBlockBlob(rs, blockBlobClient, 4 * 1024 * 1024, 20, { progress: (ev) => { assert.ok(ev.loadedBytes); eventTriggered = true; @@ -230,10 +242,10 @@ describe("Highlevel", () => { it("downloadBlobToBuffer should success", async () => { const rs = fs.createReadStream(tempFileLarge); - await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobClient, 4 * 1024 * 1024, 20); + await uploadStreamToBlockBlob(rs, blockBlobClient, 4 * 1024 * 1024, 20); const buf = Buffer.alloc(tempFileLargeLength); - await downloadBlobToBuffer(Aborter.none, buf, blockBlobClient, 0, undefined, { + await downloadBlobToBuffer(buf, blockBlobClient, 0, undefined, { blockSize: 4 * 1024 * 1024, maxRetryRequestsPerBlock: 5, parallelism: 20 @@ -245,15 +257,22 @@ describe("Highlevel", () => { it("downloadBlobToBuffer should abort", async () => { const rs = fs.createReadStream(tempFileLarge); - await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobClient, 4 * 1024 * 1024, 20); + await uploadStreamToBlockBlob(rs, blockBlobClient, 4 * 1024 * 1024, 20); try { const buf = Buffer.alloc(tempFileLargeLength); - await downloadBlobToBuffer(Aborter.timeout(1), buf, blockBlobClient, 0, undefined, { - blockSize: 4 * 1024 * 1024, - maxRetryRequestsPerBlock: 5, - parallelism: 20 - }); + await downloadBlobToBuffer( + buf, + blockBlobClient, + 0, + undefined, + { + abortSignal: Aborter.timeout(1), + blockSize: 4 * 1024 * 1024, + maxRetryRequestsPerBlock: 5, + parallelism: 20 + } + ); assert.fail(); } catch (err) { assert.ok((err.code as string).toLowerCase().includes("abort")); @@ -262,13 +281,14 @@ describe("Highlevel", () => { it("downloadBlobToBuffer should update progress event", async () => { const rs = fs.createReadStream(tempFileSmall); - await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobClient, 4 * 1024 * 1024, 10); + await uploadStreamToBlockBlob(rs, blockBlobClient, 4 * 1024 * 1024, 10); let eventTriggered = false; const buf = Buffer.alloc(tempFileSmallLength); const aborter = Aborter.none; try { - await downloadBlobToBuffer(aborter, buf, blockBlobClient, 0, undefined, { + await downloadBlobToBuffer(buf, blockBlobClient, 0, undefined, { + abortSignal: aborter, blockSize: 1 * 1024, maxRetryRequestsPerBlock: 5, parallelism: 1, @@ -283,7 +303,6 @@ describe("Highlevel", () => { it("blobclient.download should success when internal stream unexcepted ends at the stream end", async () => { const uploadResponse = await uploadFileToBlockBlob( - Aborter.none, tempFileSmall, blockBlobClient, { @@ -293,18 +312,21 @@ describe("Highlevel", () => { ); let retirableReadableStreamOptions: IRetriableReadableStreamOptions; - const downloadResponse = await blockBlobClient.download(Aborter.none, 0, undefined, { - blobAccessConditions: { - modifiedAccessConditions: { - ifMatch: uploadResponse.eTag - } - }, - maxRetryRequests: 1, - progress: (ev) => { - if (ev.loadedBytes >= tempFileSmallLength) { - retirableReadableStreamOptions.doInjectErrorOnce = true; + const downloadResponse = await blockBlobClient.download( + 0, + undefined, + { + blobAccessConditions: { + modifiedAccessConditions: { + ifMatch: uploadResponse.eTag + } + }, + maxRetryRequests: 1, + progress: ev => { + if (ev.loadedBytes >= tempFileSmallLength) { + retirableReadableStreamOptions.doInjectErrorOnce = true; + } } - } }); retirableReadableStreamOptions = (downloadResponse.readableStreamBody! as any).options; @@ -321,7 +343,6 @@ describe("Highlevel", () => { it("blobclient.download should download full data successfully when internal stream unexcepted ends", async () => { const uploadResponse = await uploadFileToBlockBlob( - Aborter.none, tempFileSmall, blockBlobClient, { @@ -332,18 +353,21 @@ describe("Highlevel", () => { let retirableReadableStreamOptions: IRetriableReadableStreamOptions; let injectedErrors = 0; - const downloadResponse = await blockBlobClient.download(Aborter.none, 0, undefined, { - blobAccessConditions: { - modifiedAccessConditions: { - ifMatch: uploadResponse.eTag - } - }, - maxRetryRequests: 3, - progress: () => { - if (injectedErrors++ < 3) { - retirableReadableStreamOptions.doInjectErrorOnce = true; + const downloadResponse = await blockBlobClient.download( + 0, + undefined, + { + blobAccessConditions: { + modifiedAccessConditions: { + ifMatch: uploadResponse.eTag + } + }, + maxRetryRequests: 3, + progress: () => { + if (injectedErrors++ < 3) { + retirableReadableStreamOptions.doInjectErrorOnce = true; + } } - } }); retirableReadableStreamOptions = (downloadResponse.readableStreamBody! as any).options; @@ -360,7 +384,6 @@ describe("Highlevel", () => { it("blobclient.download should download partial data when internal stream unexcepted ends", async () => { const uploadResponse = await uploadFileToBlockBlob( - Aborter.none, tempFileSmall, blockBlobClient, { @@ -373,18 +396,21 @@ describe("Highlevel", () => { let retirableReadableStreamOptions: IRetriableReadableStreamOptions; let injectedErrors = 0; - const downloadResponse = await blockBlobClient.download(Aborter.none, 0, partialSize, { - blobAccessConditions: { - modifiedAccessConditions: { - ifMatch: uploadResponse.eTag - } - }, - maxRetryRequests: 3, - progress: () => { - if (injectedErrors++ < 3) { - retirableReadableStreamOptions.doInjectErrorOnce = true; + const downloadResponse = await blockBlobClient.download( + 0, + partialSize, + { + blobAccessConditions: { + modifiedAccessConditions: { + ifMatch: uploadResponse.eTag + } + }, + maxRetryRequests: 3, + progress: () => { + if (injectedErrors++ < 3) { + retirableReadableStreamOptions.doInjectErrorOnce = true; + } } - } }); retirableReadableStreamOptions = (downloadResponse.readableStreamBody! as any).options; @@ -401,7 +427,6 @@ describe("Highlevel", () => { it("blobclient.download should download data failed when exceeding max stream retry requests", async () => { const uploadResponse = await uploadFileToBlockBlob( - Aborter.none, tempFileSmall, blockBlobClient, { @@ -417,7 +442,7 @@ describe("Highlevel", () => { let expectedError = false; try { - const downloadResponse = await blockBlobClient.download(Aborter.none, 0, undefined, { + const downloadResponse = await blockBlobClient.download(0, undefined, { blobAccessConditions: { modifiedAccessConditions: { ifMatch: uploadResponse.eTag @@ -442,7 +467,6 @@ describe("Highlevel", () => { it("blobclient.download should abort after retrys", async () => { const uploadResponse = await uploadFileToBlockBlob( - Aborter.none, tempFileSmall, blockBlobClient, { @@ -459,22 +483,26 @@ describe("Highlevel", () => { try { const aborter = Aborter.none; - const downloadResponse = await blockBlobClient.download(aborter, 0, undefined, { - blobAccessConditions: { - modifiedAccessConditions: { - ifMatch: uploadResponse.eTag + const downloadResponse = await blockBlobClient.download( + 0, + undefined, + { + abortSignal: aborter, + blobAccessConditions: { + modifiedAccessConditions: { + ifMatch: uploadResponse.eTag + } + }, + maxRetryRequests: 3, + progress: () => { + if (injectedErrors++ < 2) { + // Triger 2 times of retry + retirableReadableStreamOptions.doInjectErrorOnce = true; + } else { + // Trigger aborter + aborter.abort(); + } } - }, - maxRetryRequests: 3, - progress: () => { - if (injectedErrors++ < 2) { - // Triger 2 times of retry - retirableReadableStreamOptions.doInjectErrorOnce = true; - } else { - // Trigger aborter - aborter.abort(); - } - } }); retirableReadableStreamOptions = (downloadResponse.readableStreamBody! as any).options; await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadedFile); diff --git a/sdk/storage/storage-blob/test/node/pageblobclient.spec.ts b/sdk/storage/storage-blob/test/node/pageblobclient.spec.ts index 69ac64b1ec09..a60d65d64806 100644 --- a/sdk/storage/storage-blob/test/node/pageblobclient.spec.ts +++ b/sdk/storage/storage-blob/test/node/pageblobclient.spec.ts @@ -1,6 +1,5 @@ import * as assert from "assert"; -import { Aborter } from "../../src/Aborter"; import { BlobClient } from "../../src/BlobClient"; import { ContainerClient } from "../../src/ContainerClient"; import { PageBlobClient } from "../../src/PageBlobClient"; @@ -17,25 +16,25 @@ describe("PageBlobClient", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); blobName = getUniqueName("blob"); blobClient = BlobClient.fromContainerClient(containerClient, blobName); pageBlobClient = PageBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("startCopyIncremental", async () => { - await pageBlobClient.create(Aborter.none, 1024, { + await pageBlobClient.create(1024, { metadata: { sourcemeta: "val" } }); - await pageBlobClient.uploadPages(Aborter.none, "b".repeat(1024), 0, 1024); + await pageBlobClient.uploadPages("b".repeat(1024), 0, 1024); - let snapshotResult = await pageBlobClient.createSnapshot(Aborter.none); + let snapshotResult = await pageBlobClient.createSnapshot(); assert.ok(snapshotResult.snapshot); const destPageBlobClient = PageBlobClient.fromContainerClient( @@ -43,12 +42,12 @@ describe("PageBlobClient", () => { getUniqueName("page") ); - await containerClient.setAccessPolicy(Aborter.none, "container"); + await containerClient.setAccessPolicy("container"); await sleep(5 * 1000); let copySource = pageBlobClient.withSnapshot(snapshotResult.snapshot!).url; - let copyResponse = await destPageBlobClient.startCopyIncremental(Aborter.none, copySource); + let copyResponse = await destPageBlobClient.startCopyIncremental(copySource); async function waitForCopy(retries = 0) { if (retries >= 30) { @@ -62,7 +61,7 @@ describe("PageBlobClient", () => { throw new Error("Copy unexcepted aborted."); case "pending": await sleep(3000); - copyResponse = await destPageBlobClient.getProperties(Aborter.none); + copyResponse = await destPageBlobClient.getProperties(); await waitForCopy(++retries); return; case "failed": @@ -74,27 +73,27 @@ describe("PageBlobClient", () => { await waitForCopy(); - let listBlobResponse = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + let listBlobResponse = await containerClient.listBlobFlatSegment(undefined, { include: ["copy", "snapshots"] }); assert.equal(listBlobResponse.segment.blobItems.length, 4); - await pageBlobClient.uploadPages(Aborter.none, "c".repeat(1024), 0, 1024); - snapshotResult = await pageBlobClient.createSnapshot(Aborter.none); + await pageBlobClient.uploadPages("c".repeat(1024), 0, 1024); + snapshotResult = await pageBlobClient.createSnapshot(); assert.ok(snapshotResult.snapshot); copySource = pageBlobClient.withSnapshot(snapshotResult.snapshot!).url; - copyResponse = await destPageBlobClient.startCopyIncremental(Aborter.none, copySource); + copyResponse = await destPageBlobClient.startCopyIncremental(copySource); await waitForCopy(); - listBlobResponse = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + listBlobResponse = await containerClient.listBlobFlatSegment(undefined, { include: ["copy", "snapshots"] }); assert.equal(listBlobResponse.segment.blobItems.length, 6); - const pageBlobProperties = await destPageBlobClient.getProperties(Aborter.none); + const pageBlobProperties = await destPageBlobClient.getProperties(); assert.equal(pageBlobProperties.metadata!.sourcemeta, "val"); }); }); diff --git a/sdk/storage/storage-blob/test/node/sas.spec.ts b/sdk/storage/storage-blob/test/node/sas.spec.ts index 5bb8ba1872d1..3afab02093d9 100644 --- a/sdk/storage/storage-blob/test/node/sas.spec.ts +++ b/sdk/storage/storage-blob/test/node/sas.spec.ts @@ -1,7 +1,6 @@ import * as assert from "assert"; import { - Aborter, AccountSASPermissions, AccountSASResourceTypes, AccountSASServices, @@ -53,7 +52,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { StorageClient.newPipeline(new AnonymousCredential()) ); - await serviceClientWithSAS.getAccountInfo(Aborter.none); + await serviceClientWithSAS.getAccountInfo(); }); it("generateAccountSASQueryParameters should not work with invalid permission", async () => { @@ -82,7 +81,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { let error; try { - await serviceClientWithSAS.getProperties(Aborter.none); + await serviceClientWithSAS.getProperties(); } catch (err) { error = err; } @@ -116,7 +115,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { let error; try { - await serviceClientWithSAS.getProperties(Aborter.none); + await serviceClientWithSAS.getProperties(); } catch (err) { error = err; } @@ -153,7 +152,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { let error; try { - await serviceClientWithSAS.getProperties(Aborter.none); + await serviceClientWithSAS.getProperties(); } catch (err) { error = err; } @@ -174,7 +173,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { const containerName = getUniqueName("container"); const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); const containerSAS = generateBlobSASQueryParameters( { @@ -195,8 +194,8 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { StorageClient.newPipeline(new AnonymousCredential()) ); - await containerClientwithSAS.listBlobFlatSegment(Aborter.none); - await containerClient.delete(Aborter.none); + await containerClientwithSAS.listBlobFlatSegment(); + await containerClient.delete(); }); it("generateBlobSASQueryParameters should work for blob", async () => { @@ -212,11 +211,11 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { const containerName = getUniqueName("container"); const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); const blobName = getUniqueName("blob"); const blobClient = PageBlobClient.fromContainerClient(containerClient, blobName); - await blobClient.create(Aborter.none, 1024, { + await blobClient.create(1024, { blobHTTPHeaders: { blobContentType: "content-type-original" } @@ -247,14 +246,14 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { StorageClient.newPipeline(new AnonymousCredential()) ); - const properties = await blobClientwithSAS.getProperties(Aborter.none); + const properties = await blobClientwithSAS.getProperties(); assert.equal(properties.cacheControl, "cache-control-override"); assert.equal(properties.contentDisposition, "content-disposition-override"); assert.equal(properties.contentEncoding, "content-encoding-override"); assert.equal(properties.contentLanguage, "content-language-override"); assert.equal(properties.contentType, "content-type-override"); - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("generateBlobSASQueryParameters should work for blob with special namings", async () => { @@ -270,13 +269,13 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { const containerName = getUniqueName("container-with-dash"); const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); const blobName = getUniqueName( "////Upper/blob/empty /another 汉字 ру́сский язы́к ру́сский язы́к عربي/عربى にっぽんご/にほんご . special ~!@#$%^&*()_+`1234567890-={}|[]\\:\";'<>?,/'" ); const blobClient = PageBlobClient.fromContainerClient(containerClient, blobName); - await blobClient.create(Aborter.none, 1024, { + await blobClient.create(1024, { blobHTTPHeaders: { blobContentType: "content-type-original" } @@ -308,14 +307,14 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { StorageClient.newPipeline(new AnonymousCredential()) ); - const properties = await blobClientwithSAS.getProperties(Aborter.none); + const properties = await blobClientwithSAS.getProperties(); assert.equal(properties.cacheControl, "cache-control-override"); assert.equal(properties.contentDisposition, "content-disposition-override"); assert.equal(properties.contentEncoding, "content-encoding-override"); assert.equal(properties.contentLanguage, "content-language-override"); assert.equal(properties.contentType, "content-type-override"); - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("generateBlobSASQueryParameters should work for blob with access policy", async () => { @@ -331,14 +330,14 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { const containerName = getUniqueName("container"); const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); const blobName = getUniqueName("blob"); const blobClient = PageBlobClient.fromContainerClient(containerClient, blobName); - await blobClient.create(Aborter.none, 1024); + await blobClient.create(1024); const id = "unique-id"; - await containerClient.setAccessPolicy(Aborter.none, undefined, [ + await containerClient.setAccessPolicy(undefined, [ { accessPolicy: { expiry: tmr, @@ -363,7 +362,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { StorageClient.newPipeline(new AnonymousCredential()) ); - await blobClientwithSAS.getProperties(Aborter.none); - await containerClient.delete(Aborter.none); + await blobClientwithSAS.getProperties(); + await containerClient.delete(); }); }); diff --git a/sdk/storage/storage-blob/test/pageblobclient.spec.ts b/sdk/storage/storage-blob/test/pageblobclient.spec.ts index 2528490d272c..a29241d345d4 100644 --- a/sdk/storage/storage-blob/test/pageblobclient.spec.ts +++ b/sdk/storage/storage-blob/test/pageblobclient.spec.ts @@ -1,7 +1,6 @@ import * as assert from "assert"; import { bodyToString, getBSU, getUniqueName } from "./utils"; -import { Aborter } from "../src/Aborter"; import { BlobClient } from "../src/BlobClient"; import { ContainerClient } from "../src/ContainerClient"; import { PageBlobClient } from "../src/PageBlobClient"; @@ -19,20 +18,20 @@ describe("PageBlobClient", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); blobName = getUniqueName("blob"); blobClient = BlobClient.fromContainerClient(containerClient, blobName); pageBlobClient = PageBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("create with default parameters", async () => { - await pageBlobClient.create(Aborter.none, 512); + await pageBlobClient.create(512); - const result = await blobClient.download(Aborter.none, 0); + const result = await blobClient.download(0); assert.deepStrictEqual(await bodyToString(result, 512), "\u0000".repeat(512)); }); @@ -50,12 +49,12 @@ describe("PageBlobClient", () => { key2: "valb" } }; - await pageBlobClient.create(Aborter.none, 512, options); + await pageBlobClient.create(512, options); - const result = await blobClient.download(Aborter.none, 0); + const result = await blobClient.download(0); assert.deepStrictEqual(await bodyToString(result, 512), "\u0000".repeat(512)); - const properties = await blobClient.getProperties(Aborter.none); + const properties = await blobClient.getProperties(); assert.equal(properties.cacheControl, options.blobHTTPHeaders.blobCacheControl); assert.equal(properties.contentDisposition, options.blobHTTPHeaders.blobContentDisposition); assert.equal(properties.contentEncoding, options.blobHTTPHeaders.blobContentEncoding); @@ -66,67 +65,66 @@ describe("PageBlobClient", () => { }); it("uploadPages", async () => { - await pageBlobClient.create(Aborter.none, 1024); + await pageBlobClient.create(1024); - const result = await blobClient.download(Aborter.none, 0); + const result = await blobClient.download(0); assert.equal(await bodyToString(result, 1024), "\u0000".repeat(1024)); - await pageBlobClient.uploadPages(Aborter.none, "a".repeat(512), 0, 512); - await pageBlobClient.uploadPages(Aborter.none, "b".repeat(512), 512, 512); + await pageBlobClient.uploadPages("a".repeat(512), 0, 512); + await pageBlobClient.uploadPages("b".repeat(512), 512, 512); - const page1 = await pageBlobClient.download(Aborter.none, 0, 512); - const page2 = await pageBlobClient.download(Aborter.none, 512, 512); + const page1 = await pageBlobClient.download(0, 512); + const page2 = await pageBlobClient.download(512, 512); assert.equal(await bodyToString(page1, 512), "a".repeat(512)); assert.equal(await bodyToString(page2, 512), "b".repeat(512)); }); it("clearPages", async () => { - await pageBlobClient.create(Aborter.none, 1024); - let result = await blobClient.download(Aborter.none, 0); + await pageBlobClient.create(1024); + let result = await blobClient.download(0); assert.deepStrictEqual(await bodyToString(result, 1024), "\u0000".repeat(1024)); - await pageBlobClient.uploadPages(Aborter.none, "a".repeat(1024), 0, 1024); - result = await pageBlobClient.download(Aborter.none, 0, 1024); + await pageBlobClient.uploadPages("a".repeat(1024), 0, 1024); + result = await pageBlobClient.download(0, 1024); assert.deepStrictEqual(await bodyToString(result, 1024), "a".repeat(1024)); - await pageBlobClient.clearPages(Aborter.none, 0, 512); - result = await pageBlobClient.download(Aborter.none, 0, 512); + await pageBlobClient.clearPages(0, 512); + result = await pageBlobClient.download(0, 512); assert.deepStrictEqual(await bodyToString(result, 512), "\u0000".repeat(512)); }); it("getPageRanges", async () => { - await pageBlobClient.create(Aborter.none, 1024); + await pageBlobClient.create(1024); - const result = await blobClient.download(Aborter.none, 0); + const result = await blobClient.download(0); assert.deepStrictEqual(await bodyToString(result, 1024), "\u0000".repeat(1024)); - await pageBlobClient.uploadPages(Aborter.none, "a".repeat(512), 0, 512); - await pageBlobClient.uploadPages(Aborter.none, "b".repeat(512), 512, 512); + await pageBlobClient.uploadPages("a".repeat(512), 0, 512); + await pageBlobClient.uploadPages("b".repeat(512), 512, 512); - const page1 = await pageBlobClient.getPageRanges(Aborter.none, 0, 512); - const page2 = await pageBlobClient.getPageRanges(Aborter.none, 512, 512); + const page1 = await pageBlobClient.getPageRanges(0, 512); + const page2 = await pageBlobClient.getPageRanges(512, 512); assert.equal(page1.pageRange![0].end, 511); assert.equal(page2.pageRange![0].end, 1023); }); it("getPageRangesDiff", async () => { - await pageBlobClient.create(Aborter.none, 1024); + await pageBlobClient.create(1024); - const result = await blobClient.download(Aborter.none, 0); + const result = await blobClient.download(0); assert.deepStrictEqual(await bodyToString(result, 1024), "\u0000".repeat(1024)); - await pageBlobClient.uploadPages(Aborter.none, "b".repeat(1024), 0, 1024); + await pageBlobClient.uploadPages("b".repeat(1024), 0, 1024); - const snapshotResult = await pageBlobClient.createSnapshot(Aborter.none); + const snapshotResult = await pageBlobClient.createSnapshot(); assert.ok(snapshotResult.snapshot); - await pageBlobClient.uploadPages(Aborter.none, "a".repeat(512), 0, 512); - await pageBlobClient.clearPages(Aborter.none, 512, 512); + await pageBlobClient.uploadPages("a".repeat(512), 0, 512); + await pageBlobClient.clearPages(512, 512); const rangesDiff = await pageBlobClient.getPageRangesDiff( - Aborter.none, 0, 1024, snapshotResult.snapshot! @@ -138,19 +136,19 @@ describe("PageBlobClient", () => { }); it("updateSequenceNumber", async () => { - await pageBlobClient.create(Aborter.none, 1024); - let propertiesResponse = await pageBlobClient.getProperties(Aborter.none); + await pageBlobClient.create(1024); + let propertiesResponse = await pageBlobClient.getProperties(); - await pageBlobClient.updateSequenceNumber(Aborter.none, "increment"); - propertiesResponse = await pageBlobClient.getProperties(Aborter.none); + await pageBlobClient.updateSequenceNumber("increment"); + propertiesResponse = await pageBlobClient.getProperties(); assert.equal(propertiesResponse.blobSequenceNumber!, 1); - await pageBlobClient.updateSequenceNumber(Aborter.none, "update", 10); - propertiesResponse = await pageBlobClient.getProperties(Aborter.none); + await pageBlobClient.updateSequenceNumber("update", 10); + propertiesResponse = await pageBlobClient.getProperties(); assert.equal(propertiesResponse.blobSequenceNumber!, 10); - await pageBlobClient.updateSequenceNumber(Aborter.none, "max", 100); - propertiesResponse = await pageBlobClient.getProperties(Aborter.none); + await pageBlobClient.updateSequenceNumber("max", 100); + propertiesResponse = await pageBlobClient.getProperties(); assert.equal(propertiesResponse.blobSequenceNumber!, 100); }); }); diff --git a/sdk/storage/storage-blob/test/retrypolicy.spec.ts b/sdk/storage/storage-blob/test/retrypolicy.spec.ts index cf599f89ebeb..2b7caac28762 100644 --- a/sdk/storage/storage-blob/test/retrypolicy.spec.ts +++ b/sdk/storage/storage-blob/test/retrypolicy.spec.ts @@ -2,7 +2,6 @@ import { URLBuilder } from "@azure/ms-rest-js"; import * as assert from "assert"; import { RestError, StorageClient } from "../src"; -import { Aborter } from "../src/Aborter"; import { ContainerClient } from "../src/ContainerClient"; import { Pipeline } from "../src/Pipeline"; import { getBSU, getUniqueName } from "./utils"; @@ -18,11 +17,11 @@ describe("RetryPolicy", () => { beforeEach(async () => { containerName = getUniqueName("container"); containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - await containerClient.create(Aborter.none); + await containerClient.create(); }); afterEach(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("Retry Policy should work when first request fails with 500", async () => { @@ -43,9 +42,9 @@ describe("RetryPolicy", () => { keya: "vala", keyb: "valb" }; - await injectContainerClient.setMetadata(Aborter.none, metadata); + await injectContainerClient.setMetadata(metadata); - const result = await containerClient.getProperties(Aborter.none); + const result = await containerClient.getProperties(); assert.deepEqual(result.metadata, metadata); }); @@ -70,7 +69,7 @@ describe("RetryPolicy", () => { keya: "vala", keyb: "valb" }; - await injectContainerClient.setMetadata(Aborter.none, metadata); + await injectContainerClient.setMetadata(metadata); } catch (err) { hasError = true; } @@ -105,7 +104,7 @@ describe("RetryPolicy", () => { let finalRequestURL = ""; try { - const response = await injectContainerClient.getProperties(Aborter.none); + const response = await injectContainerClient.getProperties(); finalRequestURL = response._response.request.url; } catch (err) { finalRequestURL = err.request ? err.request.url : ""; diff --git a/sdk/storage/storage-blob/test/specialnaming.spec.ts b/sdk/storage/storage-blob/test/specialnaming.spec.ts index 11c1ea6a91a1..37ac940fa9ea 100644 --- a/sdk/storage/storage-blob/test/specialnaming.spec.ts +++ b/sdk/storage/storage-blob/test/specialnaming.spec.ts @@ -1,4 +1,3 @@ -import { Aborter } from "../src/Aborter"; import { BlockBlobClient } from "../src/BlockBlobClient"; import { ContainerClient } from "../src/ContainerClient"; import { getBSU, getUniqueName } from "./utils/index"; @@ -13,19 +12,19 @@ describe("Special Naming Tests", () => { const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); before(async () => { - await containerClient.create(Aborter.none); + await containerClient.create(); }); after(async () => { - await containerClient.delete(Aborter.none); + await containerClient.delete(); }); it("Should work with special container and blob names with spaces", async () => { const blobName: string = getUniqueName("blob empty"); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobClient.upload(Aborter.none, "A", 1); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -38,8 +37,8 @@ describe("Special Naming Tests", () => { containerClient.pipeline ); - await blockBlobClient.upload(Aborter.none, "A", 1); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -49,9 +48,9 @@ describe("Special Naming Tests", () => { const blobName: string = getUniqueName("////blob/empty /another"); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -64,9 +63,9 @@ describe("Special Naming Tests", () => { containerClient.pipeline ); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -76,9 +75,9 @@ describe("Special Naming Tests", () => { const blobName: string = getUniqueName("////Upper/blob/empty /another"); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -91,9 +90,9 @@ describe("Special Naming Tests", () => { containerClient.pipeline ); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -103,9 +102,9 @@ describe("Special Naming Tests", () => { const blobName: string = getUniqueName("////Upper/blob/empty /another 汉字"); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -118,9 +117,9 @@ describe("Special Naming Tests", () => { containerClient.pipeline ); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -132,9 +131,9 @@ describe("Special Naming Tests", () => { ); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { // NOTICE: Azure Storage Server will replace "\" with "/" in the blob names prefix: blobName.replace(/\\/g, "/") }); @@ -153,9 +152,9 @@ describe("Special Naming Tests", () => { containerClient.pipeline ); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { // NOTICE: Azure Storage Server will replace "\" with "/" in the blob names prefix: blobName.replace(/\\/g, "/") }); @@ -167,9 +166,9 @@ describe("Special Naming Tests", () => { const blobNameEncoded: string = encodeURIComponent(blobName); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobNameEncoded); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobNameEncoded }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -179,9 +178,9 @@ describe("Special Naming Tests", () => { const blobName: string = getUniqueName("ру́сский язы́к"); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -194,9 +193,9 @@ describe("Special Naming Tests", () => { containerClient.pipeline ); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -207,9 +206,9 @@ describe("Special Naming Tests", () => { const blobNameEncoded: string = encodeURIComponent(blobName); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobNameEncoded); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobNameEncoded }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -219,9 +218,9 @@ describe("Special Naming Tests", () => { const blobName: string = getUniqueName("عربي/عربى"); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -234,9 +233,9 @@ describe("Special Naming Tests", () => { containerClient.pipeline ); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -247,9 +246,9 @@ describe("Special Naming Tests", () => { const blobNameEncoded: string = encodeURIComponent(blobName); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobNameEncoded); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobNameEncoded }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -259,9 +258,9 @@ describe("Special Naming Tests", () => { const blobName: string = getUniqueName("にっぽんご/にほんご"); const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -274,9 +273,9 @@ describe("Special Naming Tests", () => { containerClient.pipeline ); - await blockBlobClient.upload(Aborter.none, "A", 1); - await blockBlobClient.getProperties(Aborter.none); - const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload("A", 1); + await blockBlobClient.getProperties(); + const response = await containerClient.listBlobFlatSegment(undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); diff --git a/sdk/storage/storage-blob/tsconfig.json b/sdk/storage/storage-blob/tsconfig.json index e271ee388662..eace00058c3d 100644 --- a/sdk/storage/storage-blob/tsconfig.json +++ b/sdk/storage/storage-blob/tsconfig.json @@ -20,6 +20,6 @@ "esModuleInterop": true }, "compileOnSave": true, - "exclude": ["node_modules", "./samples/*"], + "exclude": ["node_modules", "./samples/**"], "include": ["./src/**/*.ts", "./test/**/*.ts"] }