Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions sdk/storage/storage-blob/samples/typescript/advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function main() {
// Create a container
const containerName = `newcontainer${new Date().getTime()}`;
const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName);
await containerURL.create(Aborter.none);
await containerURL.create();

// Create a blob
const blobName = "newblob" + new Date().getTime();
Expand All @@ -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, blockBlobURL, {
await uploadFileToBlockBlob(localFilePath, blockBlobURL, {
blockSize: 4 * 1024 * 1024, // 4MB block size
parallelism: 20, // 20 concurrency
progress: ev => console.log(ev)
Expand All @@ -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 * 60 * 1000), // Abort uploading with timeout in 30mins
fs.createReadStream(localFilePath),
blockBlobURL,
4 * 1024 * 1024,
20,
{
abortSignal: Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins
progress: ev => console.log(ev)
}
);
Expand All @@ -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, blockBlobURL, {
await uploadBrowserDataToBlockBlob(browserFile, blockBlobURL, {
blockSize: 4 * 1024 * 1024, // 4MB block size
parallelism: 20, // 20 concurrency
progress: ev => console.log(ev)
Expand All @@ -83,12 +83,12 @@ async function main() {
const fileSize = fs.statSync(localFilePath).size;
const buffer = Buffer.alloc(fileSize);
await downloadBlobToBuffer(
Aborter.timeout(30 * 60 * 60 * 1000),
buffer,
blockBlobURL,
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)
Expand All @@ -97,7 +97,7 @@ async function main() {
console.log("downloadBlobToBuffer success");

// Delete container
await containerURL.delete(Aborter.none);
await containerURL.delete();
console.log("deleted container");
}

Expand Down
10 changes: 3 additions & 7 deletions sdk/storage/storage-blob/samples/typescript/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function main() {
const containerName = `newcontainer${new Date().getTime()}`;
const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName);

const createContainerResponse = await containerURL.create(Aborter.none);
const createContainerResponse = await containerURL.create();
console.log(
`Create container ${containerName} successfully`,
createContainerResponse.requestId
Expand All @@ -68,7 +68,6 @@ async function main() {
const blobURL = BlobURL.fromContainerURL(containerURL, blobName);
const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL);
const uploadBlobResponse = await blockBlobURL.upload(
Aborter.none,
content,
content.length
);
Expand All @@ -94,17 +93,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: Models.BlobDownloadResponse = await blobURL.download(
Aborter.none,
0
);
const downloadBlockBlobResponse: Models.BlobDownloadResponse = await blobURL.download(0);
console.log(
"Downloaded blob content",
await streamToString(downloadBlockBlobResponse.readableStreamBody!)
);

// Delete container
await containerURL.delete(Aborter.none);
await containerURL.delete();

console.log("deleted container");
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/src/Aborter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { AbortSignalLike, isNode } from "@azure/ms-rest-js";
*
* @example
* // Abort without timeout
* await blockBlobURL.upload(Aborter.none, buf, buf.length);
* await blockBlobURL.upload(buf, buf.length);
*
* @example
* // Abort container create in 1000ms
Expand Down
10 changes: 4 additions & 6 deletions sdk/storage/storage-blob/src/AppendBlobURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,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;
Expand Down Expand Up @@ -133,16 +135,14 @@ export class AppendBlobURL extends BlobURL {
* 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<Models.AppendBlobsCreateResponse>}
* @memberof AppendBlobURL
*/
public async create(
aborter: Aborter,
options: IAppendBlobCreateOptions = {}
): Promise<Models.AppendBlobCreateResponse> {
const aborter = options.abortSignal || Aborter.none;
options.accessConditions = options.accessConditions || {};
return this.appendBlobContext.create(0, {
abortSignal: aborter,
Expand All @@ -158,20 +158,18 @@ export class AppendBlobURL extends BlobURL {
* 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]
* @returns {Promise<Models.AppendBlobsAppendBlockResponse>}
* @memberof AppendBlobURL
*/
public async appendBlock(
aborter: Aborter,
body: HttpRequestBody,
contentLength: number,
options: IAppendBlobAppendBlockOptions = {}
): Promise<Models.AppendBlobAppendBlockResponse> {
const aborter = options.abortSignal || Aborter.none;
options.accessConditions = options.accessConditions || {};
return this.appendBlobContext.appendBlock(body, contentLength, {
abortSignal: aborter,
Expand Down
4 changes: 0 additions & 4 deletions sdk/storage/storage-blob/src/BlobDownloadResponse.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -436,7 +435,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
Expand All @@ -445,7 +443,6 @@ export class BlobDownloadResponse implements Models.BlobDownloadResponse {
* @memberof BlobDownloadResponse
*/
public constructor(
aborter: Aborter,
originalResponse: Models.BlobDownloadResponse,
getter: ReadableStreamGetter,
offset: number,
Expand All @@ -454,7 +451,6 @@ export class BlobDownloadResponse implements Models.BlobDownloadResponse {
) {
this.originalResponse = originalResponse;
this.blobDownloadStream = new RetriableReadableStream(
aborter,
this.originalResponse.readableStreamBody!,
getter,
offset,
Expand Down
Loading