Skip to content

Commit

Permalink
[storage] doc fix (#13087)
Browse files Browse the repository at this point in the history
* use uploadData instead of uploadBrowserData in samples: Fixes #12939

* fix client constructor doc: fixes MicrosoftDocs/azure-docs-sdk-node#1003

* Fix doc for #7097

* Mention InteractiveBrowserCredential in aad sample

* Update sdk/storage/storage-blob/samples/javascript/advanced.js

Co-authored-by: Jeremy Meng <[email protected]>

Co-authored-by: Jeremy Meng <[email protected]>
  • Loading branch information
ljian3377 and jeremymeng authored Jan 12, 2021
1 parent ea1eef0 commit af95729
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async function upload() {
);

const file = document.getElementById("file").files[0];
await blockBlobClient.uploadBrowserData(file, {
await blockBlobClient.uploadData(file, {
maxSingleShotSize: 4 * 1024 * 1024
});
}
6 changes: 3 additions & 3 deletions sdk/storage/storage-blob/samples/javascript/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ async function main() {
);
}

// Parallel uploading a browser File/Blob/ArrayBuffer in browsers with BlockBlobClient.uploadBrowserData()
// Uncomment following code in browsers because BlockBlobClient.uploadBrowserData() is only available in browsers
// Parallel uploading a browser File/Blob/ArrayBuffer in browsers with BlockBlobClient.uploadData()
// Uncomment following code in browsers because document.getElementById() is only available in browsers
/*
const browserFile = document.getElementById("fileinput").files[0];
await blockBlobClient.uploadBrowserData(browserFile, {
await blockBlobClient.uploadData(browserFile, {
blockSize: 4 * 1024 * 1024, // 4MB block size
concurrency: 20, // 20 concurrency
onProgress: ev => console.log(ev)
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/storage-blob/samples/javascript/azureAdAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

/*
ONLY AVAILABLE IN NODE.JS RUNTIME
If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
Setup :
- Reference - Authorize access to blobs and queues with Azure Active Directory from a client application
Expand Down Expand Up @@ -44,6 +45,7 @@ async function main() {
}

// ONLY AVAILABLE IN NODE.JS RUNTIME
// If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
// DefaultAzureCredential will first look for Azure Active Directory (AAD)
// client secret credentials in the following environment variables:
//
Expand Down
1 change: 1 addition & 0 deletions sdk/storage/storage-blob/samples/javascript/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async function main() {
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);

// ONLY AVAILABLE IN NODE.JS RUNTIME
// If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
// DefaultAzureCredential will first look for Azure Active Directory (AAD)
// client secret credentials in the following environment variables:
//
Expand Down
6 changes: 3 additions & 3 deletions sdk/storage/storage-blob/samples/typescript/src/advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ export async function main() {
);
}

// Parallel uploading a browser File/Blob/ArrayBuffer in browsers with BlockBlobClient.uploadBrowserData()
// Uncomment following code in browsers because BlockBlobClient.uploadBrowserData() is only available in browsers
// Parallel uploading a browser File/Blob/ArrayBuffer in browsers with BlockBlobClient.uploadData()
// Uncomment following code in browsers because document is only available in browsers
/*
const browserFile = document.getElementById("fileinput").files[0];
await blockBlobClient.uploadBrowserData(browserFile, {
await blockBlobClient.uploadData(browserFile, {
blockSize: 4 * 1024 * 1024, // 4MB block size
concurrency: 20, // 20 concurrency
onProgress: ev => console.log(ev)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

/*
ONLY AVAILABLE IN NODE.JS RUNTIME
If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
Setup :
- Reference - Authorize access to blobs and queues with Azure Active Directory from a client application
Expand Down Expand Up @@ -45,6 +46,7 @@ export async function main() {
}

// ONLY AVAILABLE IN NODE.JS RUNTIME
// If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
// DefaultAzureCredential will first look for Azure Active Directory (AAD)
// client secret credentials in the following environment variables:
//
Expand Down
1 change: 1 addition & 0 deletions sdk/storage/storage-blob/samples/typescript/src/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export async function main() {
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);

// ONLY AVAILABLE IN NODE.JS RUNTIME
// If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
// DefaultAzureCredential will first look for Azure Active Directory (AAD)
// client secret credentials in the following environment variables:
//
Expand Down
37 changes: 14 additions & 23 deletions sdk/storage/storage-blob/src/Clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5571,9 +5571,9 @@ export class PageBlobClient extends BlobClient {
* Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped.
* If a blob name includes ? or %, blob name must be encoded in the URL.
*
* @param {string} url A Client string pointing to Azure Storage blob service, such as
* "https://myaccount.blob.core.windows.net". You can append a SAS
* if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".
* @param {string} url A Client string pointing to Azure Storage page blob, such as
* "https://myaccount.blob.core.windows.net/mycontainer/pageblob". You can append a SAS
* if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer/pageblob?sasString".
* @param {StorageSharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the @azure/identity package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
* @param {StoragePipelineOptions} [options] Optional. Options to configure the HTTP pipeline.
* @memberof PageBlobClient
Expand All @@ -5586,10 +5586,10 @@ export class PageBlobClient extends BlobClient {
/**
* Creates an instance of PageBlobClient.
*
* @param {string} url A URL string pointing to Azure Storage blob, such as
* "https://myaccount.blob.core.windows.net/mycontainer/blob".
* @param {string} url A URL string pointing to Azure Storage page blob, such as
* "https://myaccount.blob.core.windows.net/mycontainer/pageblob".
* You can append a SAS if using AnonymousCredential, such as
* "https://myaccount.blob.core.windows.net/mycontainer/blob?sasString".
* "https://myaccount.blob.core.windows.net/mycontainer/pageblob?sasString".
* This method accepts an encoded URL or non-encoded URL pointing to a blob.
* Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped.
* However, if a blob name includes ? or %, blob name must be encoded in the URL.
Expand Down Expand Up @@ -7293,18 +7293,14 @@ export class ContainerClient extends StorageClient {
constructor(connectionString: string, containerName: string, options?: StoragePipelineOptions);
/**
* Creates an instance of ContainerClient.
* This method accepts an encoded URL or non-encoded URL pointing to a page blob.
* This method accepts an URL pointing to a container.
* Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped.
* If a blob name includes ? or %, blob name must be encoded in the URL.
*
* @param {string} url A URL string pointing to Azure Storage page blob, such as
* "https://myaccount.blob.core.windows.net/mycontainer/pageblob". You can
* @param {string} url A URL string pointing to Azure Storage container, such as
* "https://myaccount.blob.core.windows.net/mycontainer". You can
* append a SAS if using AnonymousCredential, such as
* "https://myaccount.blob.core.windows.net/mycontainer/pageblob?sasString".
* This method accepts an encoded URL or non-encoded URL pointing to a blob.
* Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped.
* However, if a blob name includes ? or %, blob name must be encoded in the URL.
* Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25".
* "https://myaccount.blob.core.windows.net/mycontainer?sasString".
* @param {StorageSharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the @azure/identity package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
* @param {StoragePipelineOptions} [options] Optional. Options to configure the HTTP pipeline.
* @memberof ContainerClient
Expand All @@ -7316,19 +7312,14 @@ export class ContainerClient extends StorageClient {
);
/**
* Creates an instance of ContainerClient.
* This method accepts an encoded URL or non-encoded URL pointing to a page blob.
* This method accepts an URL pointing to a container.
* Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped.
* If a blob name includes ? or %, blob name must be encoded in the URL.
*
* @param {string} url A URL string pointing to Azure Storage page blob, such as
* "https://myaccount.blob.core.windows.net/mycontainer/pageblob". You can
* @param {string} url A URL string pointing to Azure Storage container, such as
* "https://myaccount.blob.core.windows.net/mycontainer". You can
* append a SAS if using AnonymousCredential, such as
* "https://myaccount.blob.core.windows.net/mycontainer/pageblob?sasString".
* This method accepts an encoded URL or non-encoded URL pointing to a blob.
* Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped.
* However, if a blob name includes ? or %, blob name must be encoded in the URL.
* Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25".
* "https://myaccount.blob.core.windows.net/mycontainer?sasString".
* @param {Pipeline} pipeline Call newPipeline() to create a default
* pipeline, or provide a customized pipeline.
* @memberof ContainerClient
Expand Down
11 changes: 9 additions & 2 deletions sdk/storage/storage-file-datalake/samples/javascript/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
Setup: Enter your storage account name and shared key in main()
*/

const { DataLakeServiceClient, StorageSharedKeyCredential } = require("@azure/storage-file-datalake");
const {
DataLakeServiceClient,
StorageSharedKeyCredential
} = require("@azure/storage-file-datalake");

// Load the .env file if it exists
require("dotenv").config();
Expand All @@ -17,6 +20,7 @@ async function main() {
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);

// ONLY AVAILABLE IN NODE.JS RUNTIME
// If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
// DefaultAzureCredential will first look for Azure Active Directory (AAD)
// client secret credentials in the following environment variables:
//
Expand Down Expand Up @@ -52,7 +56,10 @@ async function main() {
const fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);

const createFileSystemResponse = await fileSystemClient.create();
console.log(`Create filesystem ${fileSystemName} successfully`, createFileSystemResponse.requestId);
console.log(
`Create filesystem ${fileSystemName} successfully`,
createFileSystemResponse.requestId
);

// Create a file
const content = "hello";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export async function main() {
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);

// ONLY AVAILABLE IN NODE.JS RUNTIME
// If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
// DefaultAzureCredential will first look for Azure Active Directory (AAD)
// client secret credentials in the following environment variables:
//
Expand Down
13 changes: 7 additions & 6 deletions sdk/storage/storage-file-share/src/Clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4708,8 +4708,9 @@ export class ShareFileClient extends StorageClient {
}

/**
* Upload a range of bytes to a file. Both the start and count of the
* range must be specified. The range can be up to 4 MB in size.
* Upload a range of bytes to a file. This operation can only be called on an existing file.
* It won't change the size, properties or metadata of the file.
* Both the start and count of the range must be specified. The range can be up to 4 MB in size.
*
* @param {HttpRequestBody} body Blob, string, ArrayBuffer, ArrayBufferView or a function
* which returns a new Readable stream whose offset is from data source beginning.
Expand Down Expand Up @@ -5031,7 +5032,7 @@ export class ShareFileClient extends StorageClient {
// High Level functions

/**
* Uploads a Buffer(Node)/Blob/ArrayBuffer/ArrayBufferView to an Azure File.
* Creates a new Azure File or replaces an existing Azure File, and then uploads a Buffer(Node)/Blob/ArrayBuffer/ArrayBufferView to it.
*
* @param {Buffer | Blob | ArrayBuffer | ArrayBufferView} data Buffer(Node), Blob, ArrayBuffer or ArrayBufferView
* @param {FileParallelUploadOptions} [options]
Expand Down Expand Up @@ -5120,7 +5121,7 @@ export class ShareFileClient extends StorageClient {
/**
* ONLY AVAILABLE IN NODE.JS RUNTIME.
*
* Uploads a local file to an Azure file.
* Creates a new Azure File or replaces an existing Azure File, and then uploads a local file to it.
*
* @param {string} filePath Full path of local file
* @param {ShareFileClient} fileClient ShareFileClient
Expand Down Expand Up @@ -5448,8 +5449,8 @@ export class ShareFileClient extends StorageClient {
/**
* ONLY AVAILABLE IN NODE.JS RUNTIME.
*
* Uploads a Node.js Readable stream into an Azure file.
* This method will try to create an Azure, then starts uploading chunk by chunk.
* Creates a new Azure File or replaces an existing Azure File, and then uploads a Node.js Readable stream into it.
* This method will try to create an Azure File, then starts uploading chunk by chunk.
* Size of chunk is defined by `bufferSize` parameter.
* Please make sure potential size of stream doesn't exceed file size.
*
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/storage-queue/samples/javascript/azureAdAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

/*
ONLY AVAILABLE IN NODE.JS RUNTIME
If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
Setup :
- Reference - Authorize access to blobs and queues with Azure Active Directory from a client application
Expand Down Expand Up @@ -44,6 +45,7 @@ async function main() {
}

// ONLY AVAILABLE IN NODE.JS RUNTIME
// If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
// DefaultAzureCredential will first look for Azure Active Directory (AAD)
// client secret credentials in the following environment variables:
//
Expand Down
1 change: 1 addition & 0 deletions sdk/storage/storage-queue/samples/javascript/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async function main() {
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);

// ONLY AVAILABLE IN NODE.JS RUNTIME
// If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
// DefaultAzureCredential will first look for Azure Active Directory (AAD)
// client secret credentials in the following environment variables:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

/*
ONLY AVAILABLE IN NODE.JS RUNTIME
If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
Setup :
- Reference - Authorize access to blobs and queues with Azure Active Directory from a client application
Expand Down Expand Up @@ -45,6 +46,7 @@ export async function main() {
}

// ONLY AVAILABLE IN NODE.JS RUNTIME
// If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
// DefaultAzureCredential will first look for Azure Active Directory (AAD)
// client secret credentials in the following environment variables:
//
Expand Down
1 change: 1 addition & 0 deletions sdk/storage/storage-queue/samples/typescript/src/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export async function main() {
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);

// ONLY AVAILABLE IN NODE.JS RUNTIME
// If you are using the browser, you can use the InteractiveBrowserCredential provided via @azure/identity or any other feasible implementation of TokenCredential.
// DefaultAzureCredential will first look for Azure Active Directory (AAD)
// client secret credentials in the following environment variables:
//
Expand Down

0 comments on commit af95729

Please sign in to comment.