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
9 changes: 3 additions & 6 deletions sdk/storage/storage-blob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ async function main() {
let marker;
do {
const listContainersResponse = await blobServiceClient.listContainersSegment(
Aborter.none,
marker
);

Expand All @@ -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
Expand All @@ -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
);
Expand All @@ -204,7 +202,6 @@ async function main() {
marker = undefined;
do {
const listBlobsResponse = await containerClient.listBlobFlatSegment(
Aborter.none,
marker
);

Expand All @@ -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");
}
Expand Down
12 changes: 6 additions & 6 deletions sdk/storage/storage-blob/samples/javascript/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
Expand All @@ -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)
}
);
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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");
}

Expand Down
9 changes: 3 additions & 6 deletions sdk/storage/storage-blob/samples/javascript/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ async function main() {
let marker;
do {
const listContainersResponse = await blobServiceClient.listContainersSegment(
Aborter.none,
marker
);

Expand All @@ -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
Expand All @@ -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
);
Expand All @@ -81,7 +79,6 @@ async function main() {
marker = undefined;
do {
const listBlobsResponse = await containerClient.listBlobFlatSegment(
Aborter.none,
marker
);

Expand All @@ -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");
}
Expand Down
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 containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName);
await containerClient.create(Aborter.none);
await containerClient.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, blockBlobClient, {
await uploadFileToBlockBlob(localFilePath, blockBlobClient, {
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 * 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)
}
);
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, blockBlobClient, {
await uploadBrowserDataToBlockBlob(browserFile, blockBlobClient, {
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 * 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)
Expand All @@ -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");
}

Expand Down
9 changes: 2 additions & 7 deletions sdk/storage/storage-blob/samples/typescript/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

import {
Aborter,
BlobClient,
BlockBlobClient,
ContainerClient,
Expand Down Expand Up @@ -42,7 +41,6 @@ async function main() {
let marker;
do {
const listContainersResponse: Models.ServiceListContainersSegmentResponse = await blobServiceClient.listContainersSegment(
Aborter.none,
marker
);

Expand All @@ -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
Expand All @@ -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
);
Expand All @@ -81,7 +78,6 @@ async function main() {
marker = undefined;
do {
const listBlobsResponse: Models.ContainerListBlobFlatSegmentResponse = await containerClient.listBlobFlatSegment(
Aborter.none,
marker
);

Expand All @@ -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(
Expand All @@ -104,7 +99,7 @@ async function main() {
);

// Delete container
await containerClient.delete(Aborter.none);
await containerClient.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 blockBlobClient.upload(Aborter.none, buf, buf.length);
* await blockBlobClient.upload(buf, buf.length);
*
* @example
* // Abort container create in 1000ms
Expand Down
10 changes: 4 additions & 6 deletions sdk/storage/storage-blob/src/AppendBlobClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Models.AppendBlobsCreateResponse>}
* @memberof AppendBlobClient
*/
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 @@ -153,20 +153,18 @@ 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]
* @returns {Promise<Models.AppendBlobsAppendBlockResponse>}
* @memberof AppendBlobClient
*/
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
Loading