azure-storage
Advanced tools
Comparing version 2.4.0 to 2.5.0
Note: This is the change log file for Azure Storage JavaScript Client Library. | ||
2017.09 Version 0.2.5-preview.11 | ||
* Generated browser compatible JavaScript files based on Microsoft Azure Storage SDK for Node.js 2.5.0. | ||
2017.08 Version 0.2.4-preview.10 | ||
@@ -4,0 +8,0 @@ |
@@ -13,6 +13,6 @@ # Azure Storage JavaScript Client Library for Browsers | ||
We also provide samples to guide you quickly start with the Azure Storage JavaScript Client Library. In the [JavaScript Client Library zip file](https://aka.ms/downloadazurestoragejs) or [azure-storage-node/browser/samples](samples), you will find 4 HTML samples: | ||
- `sample-table.html` demostrates how to operate with Azure Storage table service in the browser | ||
- `sample-blob.html` demostrates how to operate with Azure Storage blob service in the browser | ||
- `sample-queue.html` demostrates how to operate with Azure Storage queue service in the browser | ||
- `sample-file.html` demostrates how to operate with Azure Storage file service in the browser | ||
- `sample-table.html` demonstrates how to operate with Azure Storage table service in the browser | ||
- `sample-blob.html` demonstrates how to operate with Azure Storage blob service in the browser | ||
- `sample-queue.html` demonstrates how to operate with Azure Storage queue service in the browser | ||
- `sample-file.html` demonstrates how to operate with Azure Storage file service in the browser | ||
@@ -19,0 +19,0 @@ After generating the JavaScript Client Library, you can try the samples in browsers such as Chrome/Edge/Firefox directly. |
Note: This is an Azure Storage only package. The all up Azure node sdk still has the old storage bits in there. In a future release, those storage bits will be removed and an npm dependency to this storage node sdk will | ||
be taken. This is a GA release and the changes described below indicate the changes from the Azure node SDK 0.9.8 available here - https://github.com/Azure/azure-sdk-for-node. | ||
2017.09 Version 2.5.0 | ||
ALL | ||
* Optimized samples and documentation for retry policies. | ||
* Added additional samples for blob and file. | ||
BLOB | ||
* Optimized `commitBlocks` API implementation and documentation. | ||
FILE | ||
* Added support for File metrics. | ||
2017.08 Version 2.4.0 | ||
@@ -91,3 +103,3 @@ | ||
* Added `publicAccessLevel` to `ContainerResult` for the APIs `listContainersSegmented` and `listContainersSegmentedWithPrefix`. | ||
* When specifiying access condition `If-None-Match: *` for reading, it will always fail. | ||
* When specifying access condition `If-None-Match: *` for reading, it will always fail. | ||
* Returned content MD5 for range gets Blobs. | ||
@@ -94,0 +106,0 @@ * Fixed the issue that `useTransactionalMD5` didn't take effect for downloading a big blob. |
@@ -18,7 +18,9 @@ // | ||
/** | ||
* Demonstrates how to define a customized retry policy. | ||
* | ||
* In this sample, we define a customized retry policy which retries on the "The specified container is being deleted" | ||
* exception besides the server exceptions. | ||
* | ||
* Demonstrates how to use pre-written retry policies and how to define a customized retry policy. | ||
* | ||
* In the sample for pre-written retry policies, we simply show how to use pre-written retry policies. | ||
* | ||
* In the sample for customized retry policy, we define a customized retry policy, | ||
* which retries on the "The specified container is being deleted" exception besides the server exceptions. | ||
* | ||
* Note that only in the cloud(not the storage emulator), "The specified container is being deleted" exceptions will be | ||
@@ -47,5 +49,45 @@ * sent if users immediately recreate a container after delete it. | ||
function setRetryPolicy() { | ||
console.log('Starting continuationSample.'); | ||
/** | ||
* Demonstrate how to use pre-written retry policies. | ||
* By default, no retry will be performed with service instances newly created. | ||
* Several pre-written retry policies are available with modifiable settings, | ||
* and can be used through associating filter. | ||
*/ | ||
function setRetries() { | ||
console.log('Starting Sample 1 - setRetries.'); | ||
// By default, no retry will be performed with all kinds of services created | ||
// by Azure storage client library for Node.js. | ||
var blobServiceWithoutRetry = azure.createBlobService(); | ||
console.log('BlobService instance created, no retry will be performed by default.'); | ||
// There are two pre-written retry policies: ExponentialRetryPolicyFilter | ||
// and LinearRetryPolicyFilter can be used with modifiable settings. | ||
// Use an exponential retry with customized settings. | ||
var fileServiceWithExponentialRetry = azure.createFileService().withFilter( | ||
new azure.ExponentialRetryPolicyFilter( | ||
3, // retryCount is set to 3 times. | ||
4000, // retryInterval is set to 4 seconds. | ||
3000, // minRetryInterval is set to 3 seconds. | ||
120000 // maxRetryInterval is set to 120 seconds. | ||
)); | ||
console.log('FileService instance created and associated with ExponentialRetryPolicyFilter.'); | ||
console.log(' Retries will be performed with exponential back-off.'); | ||
// Use a default linear retry policy. | ||
var tableServiceWithLinearRetry = azure.createTableService().withFilter( | ||
new azure.LinearRetryPolicyFilter()); // By default, retryCount is set to 3 times and retryInterval is set to 30 seconds. | ||
console.log('TableService instance created and associated with LinearRetryPolicyFilter,'); | ||
console.log(' Retries will be performed with linear back-off.'); | ||
console.log('Ending Sample 1 - setRetries.'); | ||
} | ||
/** | ||
* Demonstrate how to use custom retry policy. | ||
* Any custom retry logic may be used by simply creating and setting RetryPolicyFilter instance. | ||
*/ | ||
function setCustomRetryPolicy() { | ||
console.log('Starting Sample 2 - setCustomRetryPolicy.'); | ||
// Step 1 : Set the retry policy to customized retry policy which will | ||
@@ -57,9 +99,9 @@ // not retry on any failing status code other than the excepted one. | ||
retryOnContainerBeingDeleted.shouldRetry = function(statusCode, retryData) { | ||
retryOnContainerBeingDeleted.shouldRetry = function (statusCode, retryData) { | ||
console.log(' Made the request at ' + new Date().toUTCString() + ', received StatusCode: ' + statusCode); | ||
retryInfo = {}; | ||
var retryInfo = {}; | ||
// retries on any bad status code other than 409 | ||
if (statusCode >= 300 && statusCode != 409 && statusCode != 500) { | ||
if (statusCode >= 300 && statusCode !== 409 && statusCode !== 500) { | ||
retryInfo.retryable = false; | ||
@@ -69,5 +111,5 @@ } else { | ||
var retryInfo = { | ||
retryInfo = { | ||
retryInterval: this.retryInterval + 2000 * currentCount, | ||
retryable: currentCount < this.retryCount, | ||
retryable: currentCount < this.retryCount | ||
}; | ||
@@ -89,4 +131,4 @@ } | ||
blobService.setProxy(proxy);*/ | ||
// Step 2: Create the container | ||
@@ -103,6 +145,6 @@ createContainer(function () { | ||
leaseContainer(function () { | ||
// Step 6: Delete the container | ||
deleteContainer(function () { | ||
console.log('Ending continuationSample.'); | ||
console.log('Ending Sample 2 - setCustomRetryPolicy.'); | ||
}); | ||
@@ -115,3 +157,3 @@ }); | ||
function createContainer (callback) { | ||
function createContainer(callback) { | ||
console.log('Entering createContainer.'); | ||
@@ -132,5 +174,5 @@ | ||
function fetchAttributesContainer (callback) { | ||
function fetchAttributesContainer(callback) { | ||
console.log('Entering fetchAttributesContainer.'); | ||
var options = { | ||
@@ -141,3 +183,3 @@ locationMode: LocationMode.SECONDARY_THEN_PRIMARY | ||
// Get the properties of the container. | ||
blobService.getContainerProperties(container, options, function(error) { | ||
blobService.getContainerProperties(container, options, function (error) { | ||
if (error) { | ||
@@ -167,3 +209,3 @@ console.log(error); | ||
function deleteContainer (callback) { | ||
function deleteContainer(callback) { | ||
console.log('Entering deleteContainer.'); | ||
@@ -191,2 +233,9 @@ | ||
setRetryPolicy(); | ||
function runAllSamples() { | ||
console.log("Starting retrypolicySample."); | ||
setRetries(); | ||
setCustomRetryPolicy(); | ||
console.log("Ending retrypolicySample."); | ||
} | ||
runAllSamples(); |
@@ -40,3 +40,3 @@ // | ||
*/ | ||
USER_AGENT_PRODUCT_VERSION: '2.4.0', | ||
USER_AGENT_PRODUCT_VERSION: '2.5.0', | ||
@@ -43,0 +43,0 @@ /** |
@@ -337,7 +337,7 @@ // | ||
if(table.toLowerCase() == 'tables') { | ||
if(table.toLowerCase() === 'tables') { | ||
return fail(new RangeError('Table name cannot be \'Tables\'.')); | ||
} | ||
if (table.match(/^([A-Za-z][A-Za-z0-9]{2,62})$/) !== null || table === '$MetricsCapacityBlob' || table.match(/^(\$Metrics(HourPrimary|MinutePrimary|HourSecondary|MinuteSecondary)?(Transactions)(Blob|Queue|Table))$/) !== null) | ||
if (table.match(/^([A-Za-z][A-Za-z0-9]{2,62})$/) !== null || table === '$MetricsCapacityBlob' || table.match(/^(\$Metrics(HourPrimary|MinutePrimary|HourSecondary|MinuteSecondary)?(Transactions)(Blob|Queue|Table|File))$/) !== null) | ||
{ | ||
@@ -344,0 +344,0 @@ callback(); |
@@ -34,3 +34,3 @@ // | ||
if (blockListJs.LatestBlocks) { | ||
if (_.isArray(blockListJs.LatestBlocks)) { | ||
blockListJs.LatestBlocks.forEach(function (block) { | ||
@@ -43,3 +43,3 @@ blockListDoc = blockListDoc.ele(Constants.BlobConstants.LATEST_ELEMENT) | ||
if (blockListJs.CommittedBlocks) { | ||
if (_.isArray(blockListJs.CommittedBlocks)) { | ||
blockListJs.CommittedBlocks.forEach(function (block) { | ||
@@ -52,3 +52,3 @@ blockListDoc = blockListDoc.ele(Constants.BlobConstants.COMMITTED_ELEMENT) | ||
if (blockListJs.UncommittedBlocks) { | ||
if (_.isArray(blockListJs.UncommittedBlocks)) { | ||
blockListJs.UncommittedBlocks.forEach(function (block) { | ||
@@ -55,0 +55,0 @@ blockListDoc = blockListDoc.ele(Constants.BlobConstants.UNCOMMITTED_ELEMENT) |
{ | ||
"name": "azure-storage", | ||
"author": "Microsoft Corporation", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Microsoft Azure Storage Client Library for Node.js", | ||
@@ -6,0 +6,0 @@ "typings": "typings/azure-storage/azure-storage.d.ts", |
@@ -99,3 +99,3 @@ # Microsoft Azure Storage SDK for Node.js | ||
description: entGen.String('take out the trash'), | ||
dueDate: entGen.DateTime(new Date(Date.UTC(2015, 6, 20))), | ||
dueDate: entGen.DateTime(new Date(Date.UTC(2015, 6, 20))) | ||
}; | ||
@@ -194,3 +194,3 @@ ``` | ||
Expiry: expiryDate | ||
}, | ||
} | ||
}; | ||
@@ -289,4 +289,35 @@ | ||
There are other methods for uploading files also, such as **createFileFromText** or **createFileFromStream**. | ||
To upload a file from a stream, the method **createFileFromStream** can be used. The var `myFileBuffer` in the script below is a native Node Buffer, or ArrayBuffer object if within a browser environment. | ||
```Javascript | ||
var stream = require('stream'); | ||
var azure = require('azure-storage'); | ||
var fileService = azure.createFileService(); | ||
var fileStream = new stream.Readable(); | ||
fileStream.push(myFileBuffer); | ||
fileStream.push(null); | ||
fileService.createFileFromStream('taskshare', 'taskdirectory', 'taskfile', fileStream, myFileBuffer.length, function(error, result, response) { | ||
if (!error) { | ||
// file uploaded | ||
} | ||
}); | ||
``` | ||
To create a file from a text string, the method **createFileFromText** can be used. A Node Buffer or ArrayBuffer object containing the text can also be supplied. | ||
```Javascript | ||
var azure = require('azure-storage'); | ||
var fileService = azure.createFileService(); | ||
var text = 'Hello World!'; | ||
fileService.createFileFromText('taskshare', 'taskdirectory', 'taskfile', text, function(error, result, response) { | ||
if (!error) { | ||
// file created | ||
} | ||
}); | ||
``` | ||
There are also several ways to download files. For example, **getFileToStream** downloads the file to a stream: | ||
@@ -407,2 +438,10 @@ | ||
### Retry Policies | ||
By default, no retry will be performed with service instances newly created by Azure storage client library for Node.js. | ||
Two pre-written retry polices [ExponentialRetryPolicyFilter](http://azure.github.io/azure-storage-node/ExponentialRetryPolicyFilter.html) and [LinearRetryPolicyFilter](http://azure.github.io/azure-storage-node/LinearRetryPolicyFilter.html) are available with modifiable settings, and can be used through associating filter. | ||
Any custom retry logic may be used by customizing RetryPolicyFilter instance. | ||
For how to use pre-writtern retry policies and how to define customized retry policy, please refer to **retrypolicysample** in samples directory. | ||
## Code Samples | ||
@@ -409,0 +448,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2573504
36493
536