diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ae3a35f75734..47266fffa42d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,4 +6,4 @@ For more information see the [Code of Conduct FAQ](https://opensource.microsoft. If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/). -If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-node/issues) section of the project. \ No newline at end of file +If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-js/issues) section of the project. diff --git a/README.md b/README.md index c2513450968f..c8a0f91af66d 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Documentation of the supported SDKs can be found here: - data plane SDKs like `@azure/batch`, `@azure/graph`, etc. ## Authentication + - For Node.js-based authentication, look at [@azure/ms-rest-nodeauth](https://npmjs.com/package/@azure/ms-rest-nodeauth). - For browser-based authentication, look at [@azure/ms-rest-browserauth](https://npmjs.com/package/@azure/ms-rest-browserauth). - The browser authentication storage is a little more complicated, so we encourage you to [read about how it works](https://github.com/Azure/ms-rest-browserauth/blob/master/README.md) before putting it in your application. @@ -71,8 +72,8 @@ get your code included into the project. Currently, the tests for client libraries in this repository are running against: -| | Linux (Ubuntu 16.04) | MacOS 10.13 | Windows Server 2016 | -|----------------------|----------------------|-------------|---------------------| -| **Node 8** | x | x | x | -| **Node 10** | x | x | x | -| **Node 11** | x | x | x | +| | Linux (Ubuntu 16.04) | MacOS 10.13 | Windows Server 2016 | +| ----------- | -------------------- | ----------- | ------------------- | +| **Node 8** | x | x | x | +| **Node 10** | x | x | x | +| **Node 11** | x | x | x | diff --git a/sdk/storage/CONTRIBUTING.md b/sdk/storage/CONTRIBUTING.md index 565ebab7e2f3..22bbdd5af144 100644 --- a/sdk/storage/CONTRIBUTING.md +++ b/sdk/storage/CONTRIBUTING.md @@ -1,10 +1,10 @@ -# Contribution Guideline +# Contribute Code or Provide Feedback -Hello! Thank you for being interested in contributing to our project! +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -Please make sure you've followed the instructions provided in the [Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. -## Project Setup +If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/). The Azure Storage development team uses Visual Studio Code. However, any preferred IDE or other toolset should be usable. @@ -62,7 +62,7 @@ Run tests in Browsers. After installed Chrome, the default testing browser: ```bash npm install npm run build -npm test:browser +npm run test:browser ``` Browser testing is based on Karma, you can change default testing browser by modifying karma.conf.js file. diff --git a/sdk/storage/README.md b/sdk/storage/README.md index f8a6c2a8f2fa..87a7ae522cd9 100644 --- a/sdk/storage/README.md +++ b/sdk/storage/README.md @@ -1,37 +1,38 @@ # Azure Storage SDK V10 for JavaScript -* @azure/storage-blob [![npm version](https://badge.fury.io/js/%40azure%2Fstorage-blob.svg)](https://badge.fury.io/js/%40azure%2Fstorage-blob) -* @azure/storage-file [![npm version](https://badge.fury.io/js/%40azure%2Fstorage-file.svg)](https://badge.fury.io/js/%40azure%2Fstorage-file) -* @azure/storage-queue [![npm version](https://badge.fury.io/js/%40azure%2Fstorage-queue.svg)](https://badge.fury.io/js/%40azure%2Fstorage-queue) -* [API Reference documentation](https://docs.microsoft.com/en-us/javascript/api/overview/azure/storage/client?view=azure-node-preview) +- @azure/storage-blob [![npm version](https://badge.fury.io/js/%40azure%2Fstorage-blob.svg)](https://badge.fury.io/js/%40azure%2Fstorage-blob) +- @azure/storage-file [![npm version](https://badge.fury.io/js/%40azure%2Fstorage-file.svg)](https://badge.fury.io/js/%40azure%2Fstorage-file) +- @azure/storage-queue [![npm version](https://badge.fury.io/js/%40azure%2Fstorage-queue.svg)](https://badge.fury.io/js/%40azure%2Fstorage-queue) +- [API Reference documentation](https://docs.microsoft.com/en-us/javascript/api/overview/azure/storage/client?view=azure-node-preview) +- [Advanced Examples in Wiki](https://github.com/Azure/azure-storage-js/wiki) ## Introduction -This project provides a SDK in JavaScript that makes it easy to consume Microsoft Azure Storage services. +This project provides a JavaScript SDK that makes it easy to consume Microsoft Azure Storage services from your Node.js and browser-based client applications. This respository contains the source for the latest version of the JavaScript SDK, v10. -Please note that this version of the SDK is a compete overhaul of the current [Azure Storage SDK for Node.js and JavaScript in Browsers](https://github.com/azure/azure-storage-node), and is based on the new Storage SDK architecture. +Note that this version of the SDK is based on the new Storage SDK architecture and replaces the [legacy SDK for Node.js and JavaScript in Browsers](https://github.com/azure/azure-storage-node). ### Features -* Blob Storage - * Get/Set Blob Service Properties - * Create/List/Delete Containers - * Create/Read/List/Update/Delete Block Blobs - * Create/Read/List/Update/Delete Page Blobs - * Create/Read/List/Update/Delete Append Blobs -* File Storage - * Get/Set File Service Properties - * Create/List/Delete File Shares - * Create/List/Delete File Directories - * Create/Read/List/Update/Delete Files -* Queue Storage - * Get/Set Queue Service Properties - * Create/List/Delete Queues - * Enqueue/Dequeue/Peek/Clear/Update/Delete Queue Messages -* Features new - * Asynchronous I/O for all operations using the async methods - * HttpPipeline which enables a high degree of per-request configurability - * 1-to-1 correlation with the Storage REST API for clarity and simplicity +- Blob Storage + - Get/Set Blob Service Properties + - Create/List/Delete Containers + - Create/Read/List/Update/Delete Block Blobs + - Create/Read/List/Update/Delete Page Blobs + - Create/Read/List/Update/Delete Append Blobs +- File Storage + - Get/Set File Service Properties + - Create/List/Delete File Shares + - Create/List/Delete File Directories + - Create/Read/List/Update/Delete Files +- Queue Storage + - Get/Set Queue Service Properties + - Create/List/Delete Queues + - Enqueue/Dequeue/Peek/Clear/Update/Delete Queue Messages +- Features new + - Asynchronous I/O for all operations using the async methods + - HttpPipeline which enables a high degree of per-request configurability + - 1-to-1 correlation with the Storage REST API for clarity and simplicity ### Compatibility @@ -43,14 +44,13 @@ You need polyfills to make this library work with IE11. The easiest way is to us Or you can load separate polyfills for missed ES feature(s). This library depends on following ES features which need external polyfills loaded. -* `Promise` -* `String.prototype.startsWith` -* `String.prototype.endsWith` -* `String.prototype.repeat` -* `String.prototype.includes` -* `Array.prototype.includes` -* `Object.keys` (Override IE11's `Object.keys` with ES6 polyfill forcely to enable [ES6 behavior](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#Notes)) - +- `Promise` +- `String.prototype.startsWith` +- `String.prototype.endsWith` +- `String.prototype.repeat` +- `String.prototype.includes` +- `Array.prototype.includes` +- `Object.keys` (Override IE11's `Object.keys` with ES6 polyfill forcely to enable [ES6 behavior](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#Notes)) #### Differences between Node.js and browsers @@ -58,26 +58,26 @@ There are differences between Node.js and browsers runtime. When getting start w ##### Following features, interfaces, classes or functions are only available in Node.js -* Shared Key Authorization based on account name and account key - * `SharedKeyCredential` -* Shared Access Signature(SAS) generation - * `generateAccountSASQueryParameters()` - * `generateBlobSASQueryParameters()` - * `generateFileSASQueryParameters()` - * `generateQueueSASQueryParameters()` -* Parallel uploading and downloading - * `uploadFileToBlockBlob()` - * `uploadStreamToBlockBlob()` - * `downloadBlobToBuffer()` - * `uploadFileToAzureFile()` - * `uploadStreamToAzureFile()` - * `downloadAzureFileToBuffer()` +- Shared Key Authorization based on account name and account key + - `SharedKeyCredential` +- Shared Access Signature(SAS) generation + - `generateAccountSASQueryParameters()` + - `generateBlobSASQueryParameters()` + - `generateFileSASQueryParameters()` + - `generateQueueSASQueryParameters()` +- Parallel uploading and downloading + - `uploadFileToBlockBlob()` + - `uploadStreamToBlockBlob()` + - `downloadBlobToBuffer()` + - `uploadFileToAzureFile()` + - `uploadStreamToAzureFile()` + - `downloadAzureFileToBuffer()` ##### Following features, interfaces, classes or functions are only available in browsers -* Parallel uploading and downloading - * `uploadBrowserDataToBlockBlob()` - * `uploadBrowserDataToAzureFile()` +- Parallel uploading and downloading + - `uploadBrowserDataToBlockBlob()` + - `uploadBrowserDataToAzureFile()` ## Getting Started @@ -85,7 +85,7 @@ There are differences between Node.js and browsers runtime. When getting start w The preferred way to install the Azure Storage SDK for JavaScript is to use the npm package manager. Take "@azure/storage-blob" for example. -Simply type the following into a terminal window: +Simply type the following into a terminal window: ```bash npm install @azure/storage-blob @@ -115,17 +115,17 @@ To use the SDK with JS bundle in the browsers, simply add a script tag to your H The JS bundled file is compatible with [UMD](https://github.com/umdjs/umd) standard, if no module system found, following global variable(s) will be exported: -* `azblob` -* `azfile` -* `azqueue` +- `azblob` +- `azfile` +- `azqueue` #### Download Download latest released JS bundles from links in the [GitHub release page](https://github.com/Azure/azure-storage-js/releases). Or from following links directly: -* Blob [https://aka.ms/downloadazurestoragejsblob](https://aka.ms/downloadazurestoragejsblob) -* File [https://aka.ms/downloadazurestoragejsfile](https://aka.ms/downloadazurestoragejsfile) -* Queue [https://aka.ms/downloadazurestoragejsqueue](https://aka.ms/downloadazurestoragejsqueue) +- Blob [https://aka.ms/downloadazurestoragejsblob](https://aka.ms/downloadazurestoragejsblob) +- File [https://aka.ms/downloadazurestoragejsfile](https://aka.ms/downloadazurestoragejsfile) +- Queue [https://aka.ms/downloadazurestoragejsqueue](https://aka.ms/downloadazurestoragejsqueue) ### CORS @@ -133,19 +133,19 @@ You need to set up [Cross-Origin Resource Sharing (CORS)](https://docs.microsoft For example, you can create following CORS settings for debugging. But please customize the settings carefully according to your requirements in production environment. -* Allowed origins: \* -* Allowed verbs: DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT -* Allowed headers: \* -* Exposed headers: \* -* Maximum age (seconds): 86400 +- Allowed origins: \* +- Allowed verbs: DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT +- Allowed headers: \* +- Exposed headers: \* +- Maximum age (seconds): 86400 ## SDK Architecture The Azure Storage SDK for JavaScript provides low-level and high-level APIs. Take Blob SDK as example: -* ServiceURL, ContainerURL and BlobURL objects provide the low-level API functionality and map one-to-one to the [Azure Storage Blob REST APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api). +- ServiceURL, ContainerURL and BlobURL objects provide the low-level API functionality and map one-to-one to the [Azure Storage Blob REST APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api). -* The high-level APIs provide convenience abstractions such as uploading a large stream to a block blob (using multiple PutBlock requests). +- The high-level APIs provide convenience abstractions such as uploading a large stream to a block blob (using multiple PutBlock requests). ## Code Samples @@ -280,12 +280,13 @@ main() ## More Samples -* [Blob Storage Examples](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob/samples) -* [Blob Storage Examples - Test Cases](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob/test/) -* [File Storage Examples](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-file/samples) -* [File Storage Examples - Test Cases](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-file/test/) -* [Queue Storage Examples](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-queue/samples) -* [Queue Storage Examples - Test Cases](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-queue/test/) +- [Advanced Examples in Wiki](https://github.com/Azure/azure-storage-js/wiki) +- [Blob Storage Examples](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob/samples) +- [Blob Storage Examples - Test Cases](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob/test/) +- [File Storage Examples](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-file/samples) +- [File Storage Examples - Test Cases](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-file/test/) +- [Queue Storage Examples](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-queue/samples) +- [Queue Storage Examples - Test Cases](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-queue/test/) ## License diff --git a/sdk/storage/storage-blob/ChangeLog.md b/sdk/storage/storage-blob/ChangeLog.md index 7f7a6ccfd5f2..3bd9193b3519 100644 --- a/sdk/storage/storage-blob/ChangeLog.md +++ b/sdk/storage/storage-blob/ChangeLog.md @@ -1,5 +1,8 @@ # Changelog +* Improved comments for `BlockBlobURL.upload()`. +* Exported `HttpRequestBody` type for who wants to implement a customized HTTP client. + 2018.12 10.3.0 * [Breaking] Updated convenience layer methods enum type parameters into typescript union types, this will help reducing bundle footprint. diff --git a/sdk/storage/storage-blob/README.md b/sdk/storage/storage-blob/README.md index be82d5194621..73fbabf9cd45 100644 --- a/sdk/storage/storage-blob/README.md +++ b/sdk/storage/storage-blob/README.md @@ -1,7 +1,8 @@ # Azure Storage SDK V10 for JavaScript - Blob -* [![npm version](https://badge.fury.io/js/%40azure%2Fstorage-blob.svg)](https://badge.fury.io/js/%40azure%2Fstorage-blob) -* [API Reference documentation](https://docs.microsoft.com/en-us/javascript/api/%40azure/storage-blob/index?view=azure-node-preview) +- [![npm version](https://badge.fury.io/js/%40azure%2Fstorage-blob.svg)](https://badge.fury.io/js/%40azure%2Fstorage-blob) +- [API Reference documentation](https://docs.microsoft.com/en-us/javascript/api/%40azure/storage-blob/index?view=azure-node-preview) +- [Advanced Examples in Wiki](https://github.com/Azure/azure-storage-js/wiki) ## Introduction @@ -11,16 +12,16 @@ Please note that this version of the SDK is a compete overhaul of the current [A ### Features -* Blob Storage - * Get/Set Blob Service Properties - * Create/List/Delete Containers - * Create/Read/List/Update/Delete Block Blobs - * Create/Read/List/Update/Delete Page Blobs - * Create/Read/List/Update/Delete Append Blobs -* Features new - * Asynchronous I/O for all operations using the async methods - * HttpPipeline which enables a high degree of per-request configurability - * 1-to-1 correlation with the Storage REST API for clarity and simplicity +- Blob Storage + - Get/Set Blob Service Properties + - Create/List/Delete Containers + - Create/Read/List/Update/Delete Block Blobs + - Create/Read/List/Update/Delete Page Blobs + - Create/Read/List/Update/Delete Append Blobs +- Features new + - Asynchronous I/O for all operations using the async methods + - HttpPipeline which enables a high degree of per-request configurability + - 1-to-1 correlation with the Storage REST API for clarity and simplicity ### Compatibility @@ -32,13 +33,13 @@ You need polyfills to make this library work with IE11. The easiest way is to us Or you can load separate polyfills for missed ES feature(s). This library depends on following ES features which need external polyfills loaded. -* `Promise` -* `String.prototype.startsWith` -* `String.prototype.endsWith` -* `String.prototype.repeat` -* `String.prototype.includes` -* `Array.prototype.includes` -* `Object.keys` (Override IE11's `Object.keys` with ES6 polyfill forcely to enable [ES6 behavior](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#Notes)) +- `Promise` +- `String.prototype.startsWith` +- `String.prototype.endsWith` +- `String.prototype.repeat` +- `String.prototype.includes` +- `Array.prototype.includes` +- `Object.keys` (Override IE11's `Object.keys` with ES6 polyfill forcely to enable [ES6 behavior](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#Notes)) #### Differences between Node.js and browsers @@ -46,20 +47,20 @@ There are differences between Node.js and browsers runtime. When getting start w ##### Following features, interfaces, classes or functions are only available in Node.js -* Shared Key Authorization based on account name and account key - * `SharedKeyCredential` -* Shared Access Signature(SAS) generation - * `generateAccountSASQueryParameters()` - * `generateBlobSASQueryParameters()` -* Parallel uploading and downloading - * `uploadFileToBlockBlob()` - * `uploadStreamToBlockBlob()` - * `downloadBlobToBuffer()` +- Shared Key Authorization based on account name and account key + - `SharedKeyCredential` +- Shared Access Signature(SAS) generation + - `generateAccountSASQueryParameters()` + - `generateBlobSASQueryParameters()` +- Parallel uploading and downloading + - `uploadFileToBlockBlob()` + - `uploadStreamToBlockBlob()` + - `downloadBlobToBuffer()` ##### Following features, interfaces, classes or functions are only available in browsers -* Parallel uploading and downloading - * `uploadBrowserDataToBlockBlob()` +- Parallel uploading and downloading + - `uploadBrowserDataToBlockBlob()` ## Getting Started @@ -93,13 +94,13 @@ To use the SDK with JS bundle in the browsers, simply add a script tag to your H The JS bundled file is compatible with [UMD](https://github.com/umdjs/umd) standard, if no module system found, following global variable(s) will be exported: -* `azblob` +- `azblob` #### Download Download latest released JS bundles from links in the [GitHub release page](https://github.com/Azure/azure-sdk-for-js/releases). Or from following links directly: -* Blob [https://aka.ms/downloadazurestoragejsblob](https://aka.ms/downloadazurestoragejsblob) +- Blob [https://aka.ms/downloadazurestoragejsblob](https://aka.ms/downloadazurestoragejsblob) ### CORS @@ -107,19 +108,19 @@ You need to set up [Cross-Origin Resource Sharing (CORS)](https://docs.microsoft For example, you can create following CORS settings for debugging. But please customize the settings carefully according to your requirements in production environment. -* Allowed origins: \* -* Allowed verbs: DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT -* Allowed headers: \* -* Exposed headers: \* -* Maximum age (seconds): 86400 +- Allowed origins: \* +- Allowed verbs: DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT +- Allowed headers: \* +- Exposed headers: \* +- Maximum age (seconds): 86400 ## SDK Architecture The Azure Storage SDK for JavaScript provides low-level and high-level APIs. -* ServiceURL, ContainerURL and BlobURL objects provide the low-level API functionality and map one-to-one to the [Azure Storage Blob REST APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api). +- ServiceURL, ContainerURL and BlobURL objects provide the low-level API functionality and map one-to-one to the [Azure Storage Blob REST APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api). -* The high-level APIs provide convenience abstractions such as uploading a large stream to a block blob (using multiple PutBlock requests). +- The high-level APIs provide convenience abstractions such as uploading a large stream to a block blob (using multiple PutBlock requests). ## Code Samples @@ -254,8 +255,9 @@ main() ## More Code Samples -* [Blob Storage Examples](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob/samples) -* [Blob Storage Examples - Test Cases](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob/test/) +- [Advanced Examples in Wiki](https://github.com/Azure/azure-storage-js/wiki) +- [Blob Storage Examples](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob/samples) +- [Blob Storage Examples - Test Cases](https://github.com/azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob/test/) ## License diff --git a/sdk/storage/storage-blob/samples/javascript/advanced.js b/sdk/storage/storage-blob/samples/javascript/advanced.js index 8050cfae77d1..a605271784f0 100644 --- a/sdk/storage/storage-blob/samples/javascript/advanced.js +++ b/sdk/storage/storage-blob/samples/javascript/advanced.js @@ -26,12 +26,8 @@ async function main() { const pipeline = StorageURL.newPipeline(new AnonymousCredential(), { // httpClient: MyHTTPClient, // A customized HTTP client implementing IHttpClient interface // logger: MyLogger, // A customized logger implementing IHttpPipelineLogger interface - retryOptions: { - maxTries: 4 - }, // Retry options - telemetry: { - value: "HighLevelSample V1.0.0" - } // Customized telemetry string + retryOptions: { maxTries: 4 }, // Retry options + telemetry: { value: "HighLevelSample V1.0.0" } // Customized telemetry string }); const serviceURL = new ServiceURL( @@ -61,11 +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 * 60 * 1000), // Abort uploading with timeout in 30mins + Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins fs.createReadStream(localFilePath), blockBlobURL, 4 * 1024 * 1024, - 20, { + 20, + { progress: ev => console.log(ev) } ); @@ -87,11 +84,12 @@ async function main() { const fileSize = fs.statSync(localFilePath).size; const buffer = Buffer.alloc(fileSize); await downloadBlobToBuffer( - Aborter.timeout(30 * 60 * 60 * 1000), + Aborter.timeout(30 * 60 * 1000), buffer, blockBlobURL, 0, - undefined, { + undefined, + { blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -111,4 +109,4 @@ main() }) .catch(err => { console.log(err.message); - }); \ No newline at end of file + }); diff --git a/sdk/storage/storage-blob/samples/typescript/advanced.ts b/sdk/storage/storage-blob/samples/typescript/advanced.ts index 9fa45ea7f453..c9081e0c5717 100644 --- a/sdk/storage/storage-blob/samples/typescript/advanced.ts +++ b/sdk/storage/storage-blob/samples/typescript/advanced.ts @@ -56,7 +56,7 @@ 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 + Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins fs.createReadStream(localFilePath), blockBlobURL, 4 * 1024 * 1024, @@ -83,7 +83,7 @@ async function main() { const fileSize = fs.statSync(localFilePath).size; const buffer = Buffer.alloc(fileSize); await downloadBlobToBuffer( - Aborter.timeout(30 * 60 * 60 * 1000), + Aborter.timeout(30 * 60 * 1000), buffer, blockBlobURL, 0, diff --git a/sdk/storage/storage-blob/src/BlockBlobURL.ts b/sdk/storage/storage-blob/src/BlockBlobURL.ts index 0a89318d765a..db811a17ceb1 100644 --- a/sdk/storage/storage-blob/src/BlockBlobURL.ts +++ b/sdk/storage/storage-blob/src/BlockBlobURL.ts @@ -158,8 +158,10 @@ export class BlockBlobURL extends BlobURL { * * @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 {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 + * string including non non-Base64/Hex-encoded characters. * @param {IBlockBlobUploadOptions} [options] * @returns {Promise} * @memberof BlockBlobURL diff --git a/sdk/storage/storage-blob/src/Pipeline.ts b/sdk/storage/storage-blob/src/Pipeline.ts index ee400f3d6e82..4d5262d1d0a6 100644 --- a/sdk/storage/storage-blob/src/Pipeline.ts +++ b/sdk/storage/storage-blob/src/Pipeline.ts @@ -5,6 +5,7 @@ import { HttpOperationResponse, HttpPipelineLogger as IHttpPipelineLogger, HttpPipelineLogLevel, + HttpRequestBody, RequestPolicy, RequestPolicyFactory, RequestPolicyOptions, @@ -19,6 +20,7 @@ export { IHttpPipelineLogger, HttpHeaders, HttpPipelineLogLevel, + HttpRequestBody, HttpOperationResponse, WebResource, BaseRequestPolicy, diff --git a/sdk/storage/storage-blob/test/bloburl.test.ts b/sdk/storage/storage-blob/test/bloburl.test.ts index fdf4e93c39a8..9f449486e4fb 100644 --- a/sdk/storage/storage-blob/test/bloburl.test.ts +++ b/sdk/storage/storage-blob/test/bloburl.test.ts @@ -7,8 +7,7 @@ import { BlockBlobURL } from "../src/BlockBlobURL"; import { ContainerURL } from "../src/ContainerURL"; import { bodyToString, getBSU, getUniqueName, sleep } from "./utils"; import * as dotenv from "dotenv"; -dotenv.config({path:"../.env"}); - +dotenv.config({ path: "../.env" }); describe("BlobURL", () => { const serviceURL = getBSU(); let containerName: string = getUniqueName("container"); @@ -147,7 +146,8 @@ describe("BlobURL", () => { assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await sleep(16 * 1000); + await sleep(20 * 1000); + const result2 = await blobURL.getProperties(Aborter.none); assert.ok(!result2.leaseDuration); assert.equal(result2.leaseState, "expired"); @@ -189,14 +189,14 @@ describe("BlobURL", () => { assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await blobURL.breakLease(Aborter.none, 3); + await blobURL.breakLease(Aborter.none, 5); const result2 = await blobURL.getProperties(Aborter.none); assert.ok(!result2.leaseDuration); assert.equal(result2.leaseState, "breaking"); assert.equal(result2.leaseStatus, "locked"); - await sleep(3 * 1000); + await sleep(5 * 1000); const result3 = await blobURL.getProperties(Aborter.none); assert.ok(!result3.leaseDuration); diff --git a/sdk/storage/storage-blob/test/node/pagebloburl.test.ts b/sdk/storage/storage-blob/test/node/pagebloburl.test.ts index 4e7861bd89b1..12b3a1d9118f 100644 --- a/sdk/storage/storage-blob/test/node/pagebloburl.test.ts +++ b/sdk/storage/storage-blob/test/node/pagebloburl.test.ts @@ -44,6 +44,9 @@ describe("PageBlobURL", () => { ); await containerURL.setAccessPolicy(Aborter.none, "container"); + + await sleep(5 * 1000); + let copySource = pageBlobURL.withSnapshot(snapshotResult.snapshot!).url; let copyResponse = await destPageBlobURL.startCopyIncremental( Aborter.none, diff --git a/sdk/storage/storage-file/samples/javascript/advanced.js b/sdk/storage/storage-file/samples/javascript/advanced.js index 3ae6fb564f17..d21156030c02 100644 --- a/sdk/storage/storage-file/samples/javascript/advanced.js +++ b/sdk/storage/storage-file/samples/javascript/advanced.js @@ -26,12 +26,8 @@ async function main() { const pipeline = StorageURL.newPipeline(new AnonymousCredential(), { // httpClient: MyHTTPClient, // A customized HTTP client implementing IHttpClient interface // logger: MyLogger, // A customized logger implementing IHttpPipelineLogger interface - retryOptions: { - maxTries: 4 - }, // Retry options - telemetry: { - value: "HighLevelSample V1.0.0" - } // Customized telemetry string + retryOptions: { maxTries: 4 }, // Retry options + telemetry: { value: "HighLevelSample V1.0.0" } // Customized telemetry string }); const serviceURL = new ServiceURL( @@ -68,12 +64,13 @@ async function main() { // Parallel uploading a Readable stream with uploadStreamToAzureFile in Node.js runtime // uploadStreamToAzureFile is only available in Node.js await uploadStreamToAzureFile( - Aborter.timeout(30 * 60 * 60 * 1000), // Abort uploading with timeout in 30mins + Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins fs.createReadStream(localFilePath), fileSize, fileURL, 4 * 1024 * 1024, - 20, { + 20, + { progress: ev => console.log(ev) } ); @@ -94,11 +91,12 @@ async function main() { // downloadAzureFileToBuffer is only available in Node.js const buffer = Buffer.alloc(fileSize); await downloadAzureFileToBuffer( - Aborter.timeout(30 * 60 * 60 * 1000), + Aborter.timeout(30 * 60 * 1000), buffer, fileURL, 0, - undefined, { + undefined, + { rangeSize: 4 * 1024 * 1024, // 4MB range size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -118,4 +116,4 @@ main() }) .catch(err => { console.log(err.message); - }); \ No newline at end of file + }); diff --git a/sdk/storage/storage-file/samples/typescript/advanced.ts b/sdk/storage/storage-file/samples/typescript/advanced.ts index 9cc81aa7c302..e38e7e4aa4d9 100644 --- a/sdk/storage/storage-file/samples/typescript/advanced.ts +++ b/sdk/storage/storage-file/samples/typescript/advanced.ts @@ -63,7 +63,7 @@ async function main() { // Parallel uploading a Readable stream with uploadStreamToAzureFile in Node.js runtime // uploadStreamToAzureFile is only available in Node.js await uploadStreamToAzureFile( - Aborter.timeout(30 * 60 * 60 * 1000), // Abort uploading with timeout in 30mins + Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins fs.createReadStream(localFilePath), fileSize, fileURL, @@ -90,7 +90,7 @@ async function main() { // downloadAzureFileToBuffer is only available in Node.js const buffer = Buffer.alloc(fileSize); await downloadAzureFileToBuffer( - Aborter.timeout(30 * 60 * 60 * 1000), + Aborter.timeout(30 * 60 * 1000), buffer, fileURL, 0,