Skip to content

Commit

Permalink
Merge pull request #27 from XiaoningLiu/10.2.0-preview-release
Browse files Browse the repository at this point in the history
10.2.0 preview release
  • Loading branch information
vinjiang authored Nov 28, 2018
2 parents f9deab4 + d84fd99 commit 09f6a7f
Show file tree
Hide file tree
Showing 39 changed files with 2,931 additions and 824 deletions.
49 changes: 24 additions & 25 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ The Azure Storage development team uses Visual Studio Code. However, any preferr

### Install

- Node.js valid LTS versions (>=6.5.0)
- Browsers like Chrome, Edge or Firefox
- Clone the source code from GitHub
* Node.js valid LTS versions (>=6.5.0)
* Browsers like Chrome, Edge or Firefox
* Clone the source code from GitHub

## Tests

Expand All @@ -32,24 +32,19 @@ You need to set up CORS rules for your storage account if you need to develop fo

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

### Building

This project is based on TypeScript. For Node.js, generate commonJS module formats, build with:
This project is based on TypeScript. For Node.js, generate commonJS module formats and browser bundles, build with:

```bash
npm run build:cjs
```

Generate JavaScript bundles for browsers:

```bash
npm run build:browser
npm install
npm run build
```

### Running
Expand All @@ -58,16 +53,20 @@ To actually run tests in Node.js:

```bash
npm install
npm run build
npm run test:node
```

Run tests in Browsers. After installed Chrome, the default testing browser:

```bash
npm install
npm run build
npm test:browser
```

Browser testing is based on Karma, you can change default testing browser by modifying karma.conf.js file.

### Testing Features

As you develop a feature, you'll need to write tests to ensure quality. You should also run existing tests related to your change to address any unexpected breaks in both Node.js and Browsers.
Expand All @@ -78,16 +77,16 @@ As you develop a feature, you'll need to write tests to ensure quality. You shou

The following are the minimum requirements for any pull request that must be met before contributions can be accepted.

- Make sure you've signed the CLA before you start working on any change.
- Discuss any proposed contribution with the team via a GitHub issue **before** starting development.
- Code must be professional quality
- No style issues
- You should strive to mimic the style with which we have written the library
- Clean, well-commented, well-designed code
- Try to limit the number of commits for a feature to 1-2. If you end up having too many we may ask you to squash your changes into fewer commits.
* Make sure you've signed the CLA before you start working on any change.
* Discuss any proposed contribution with the team via a GitHub issue **before** starting development.
* Code must be professional quality
* No style issues
* You should strive to mimic the style with which we have written the library
* Clean, well-commented, well-designed code
* Try to limit the number of commits for a feature to 1-2. If you end up having too many we may ask you to squash your changes into fewer commits.

- ChangeLog.md needs to be updated describing the new change
- Thoroughly test your feature
* ChangeLog.md needs to be updated describing the new change
* Thoroughly test your feature

### Branching Policy

Expand Down
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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)
* [API Reference documentation](https://docs.microsoft.com/en-us/javascript/api/overview/azure/storage/client?view=azure-node-preview)

## Introduction

Expand Down Expand Up @@ -39,7 +40,7 @@ This library depends on following ES6 features which need external polyfills loa

#### Differences between Node.js and browsers

There are differences between Node.js and browsers runtime. When getting start with this SDK, pay attention to APIs or classes marked with *"ONLY AVAILABLE IN NODE.JS RUNTIME"* or *"ONLY AVAILABLE IN BROWSERS"*.
There are differences between Node.js and browsers runtime. When getting start with this SDK, pay attention to APIs or classes marked with _"ONLY AVAILABLE IN NODE.JS RUNTIME"_ or _"ONLY AVAILABLE IN BROWSERS"_.

##### Following features, interfaces, classes or functions are only available in Node.js

Expand Down Expand Up @@ -104,10 +105,10 @@ 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 origins: \*
* Allowed verbs: DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT
* Allowed headers: *
* Exposed headers: *
* Allowed headers: \*
* Exposed headers: \*
* Maximum age (seconds): 86400

## SDK Architecture
Expand Down Expand Up @@ -143,12 +144,12 @@ async function main() {

// Use TokenCredential with OAuth token
const tokenCredential = new TokenCredential("token");
tokenCredential.token = "renewedToken";
tokenCredential.token = "renewedToken"; // Renew the token by updating token field of token credential

// Use AnonymousCredential when url already includes a SAS signature
const anonymousCredential = new AnonymousCredential();

// Use sharedKeyCredential, tokenCredential or tokenCredential to create a pipeline
// Use sharedKeyCredential, tokenCredential or anonymousCredential to create a pipeline
const pipeline = StorageURL.newPipeline(sharedKeyCredential);

// List containers
Expand All @@ -165,7 +166,7 @@ async function main() {
marker
);

marker = listContainersResponse.marker;
marker = listContainersResponse.nextMarker;
for (const container of listContainersResponse.containerItems) {
console.log(`Container: ${container.name}`);
}
Expand Down Expand Up @@ -197,13 +198,14 @@ async function main() {
);

// List blobs
marker = undefined;
do {
const listBlobsResponse = await containerURL.listBlobFlatSegment(
Aborter.none,
marker
);

marker = listBlobsResponse.marker;
marker = listBlobsResponse.nextMarker;
for (const blob of listBlobsResponse.segment.blobItems) {
console.log(`Blob: ${blob.name}`);
}
Expand All @@ -215,7 +217,7 @@ async function main() {
const downloadBlockBlobResponse = await blobURL.download(Aborter.none, 0);
console.log(
"Downloaded blob content",
downloadBlockBlobResponse.readableStreamBody.read(content.length).toString()
await streamToString(downloadBlockBlobResponse.readableStreamBody)
);

// Delete container
Expand All @@ -224,6 +226,20 @@ async function main() {
console.log("deleted container");
}

// A helper method used to read a Node.js readable stream into string
async function streamToString(readableStream) {
return new Promise((resolve, reject) => {
const chunks = [];
readableStream.on("data", data => {
chunks.push(data.toString());
});
readableStream.on("end", () => {
resolve(chunks.join(""));
});
readableStream.on("error", reject);
});
}

// An async method returns a Promise object, which is compatible with then().catch() coding style.
main()
.then(() => {
Expand Down
5 changes: 5 additions & 0 deletions blob/BreakingChanges.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Breaking Changes

2018.11 10.2.0-preview

* Updated names of exported interfaces `IHTTPPipelineLogger` & `IHTTPClient` to `IHttpPipelineLogger` & `IHttpClient`.
* For `setMetadata()` and `setHTTPHeaders()`, `metadata` and `blobHTTPHeaders` are moved from `options` into top level parameter list.

2018.09 10.1.0-preview

* `Aborter.None` is renamed to `Aborter.none` for JavaScript naming conventions.
Expand Down
14 changes: 14 additions & 0 deletions blob/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

2018.11 10.2.0-preview

* [Breaking] Updated names of exported interfaces `IHTTPPipelineLogger` & `IHTTPClient` to `IHttpPipelineLogger` & `IHttpClient`.
* [Breaking] For `setMetadata()` and `setHTTPHeaders()`, `metadata` and `blobHTTPHeaders` are moved from `options` into top level parameter list.
* Fixed bugs and typos in samples.
* Fixed a bug during generateAccountSASQueryParameters() that generated signature is not valid.
* Fixed a bug during generateBlobSASQueryParameters() that cache-control, content-type, content-disposition, content-encoding and content-language are not supported.
* Fixed a bug in SAS generation that start and expiry time format is not correct.
* Removed `File` from `uploadBrowserDataToBlockBlob` parameter type list, because `File` extends `Blob` which is already in the list.
* Fixed typos in `IRange` comments.
* Removed useless `marker` field from option of `ServiceURL.listContainersSegment` method.
* Fixed a bug that `timeout` parameter should use second as unit instead of millisecond.
* Added stream retry when `BlobURL.download` response stream unexcepted ends.

2018.09 10.1.0-preview

* Fixed sharedkey authentication error when blob names have spaces.
Expand Down
36 changes: 26 additions & 10 deletions blob/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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)
* [![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)

## Introduction

Expand Down Expand Up @@ -39,7 +40,7 @@ This library depends on following ES6 features which need external polyfills loa

#### Differences between Node.js and browsers

There are differences between Node.js and browsers runtime. When getting start with this SDK, pay attention to APIs or classes marked with *"ONLY AVAILABLE IN NODE.JS RUNTIME"* or *"ONLY AVAILABLE IN BROWSERS"*.
There are differences between Node.js and browsers runtime. When getting start with this SDK, pay attention to APIs or classes marked with _"ONLY AVAILABLE IN NODE.JS RUNTIME"_ or _"ONLY AVAILABLE IN BROWSERS"_.

##### Following features, interfaces, classes or functions are only available in Node.js

Expand Down Expand Up @@ -104,10 +105,10 @@ 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 origins: \*
* Allowed verbs: DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT
* Allowed headers: *
* Exposed headers: *
* Allowed headers: \*
* Exposed headers: \*
* Maximum age (seconds): 86400

## SDK Architecture
Expand Down Expand Up @@ -143,12 +144,12 @@ async function main() {

// Use TokenCredential with OAuth token
const tokenCredential = new TokenCredential("token");
tokenCredential.token = "renewedToken";
tokenCredential.token = "renewedToken"; // Renew the token by updating token field of token credential

// Use AnonymousCredential when url already includes a SAS signature
const anonymousCredential = new AnonymousCredential();

// Use sharedKeyCredential, tokenCredential or tokenCredential to create a pipeline
// Use sharedKeyCredential, tokenCredential or anonymousCredential to create a pipeline
const pipeline = StorageURL.newPipeline(sharedKeyCredential);

// List containers
Expand All @@ -165,7 +166,7 @@ async function main() {
marker
);

marker = listContainersResponse.marker;
marker = listContainersResponse.nextMarker;
for (const container of listContainersResponse.containerItems) {
console.log(`Container: ${container.name}`);
}
Expand Down Expand Up @@ -197,13 +198,14 @@ async function main() {
);

// List blobs
marker = undefined;
do {
const listBlobsResponse = await containerURL.listBlobFlatSegment(
Aborter.none,
marker
);

marker = listBlobsResponse.marker;
marker = listBlobsResponse.nextMarker;
for (const blob of listBlobsResponse.segment.blobItems) {
console.log(`Blob: ${blob.name}`);
}
Expand All @@ -215,7 +217,7 @@ async function main() {
const downloadBlockBlobResponse = await blobURL.download(Aborter.none, 0);
console.log(
"Downloaded blob content",
downloadBlockBlobResponse.readableStreamBody.read(content.length).toString()
await streamToString(downloadBlockBlobResponse.readableStreamBody)
);

// Delete container
Expand All @@ -224,6 +226,20 @@ async function main() {
console.log("deleted container");
}

// A helper method used to read a Node.js readable stream into string
async function streamToString(readableStream) {
return new Promise((resolve, reject) => {
const chunks = [];
readableStream.on("data", data => {
chunks.push(data.toString());
});
readableStream.on("end", () => {
resolve(chunks.join(""));
});
readableStream.on("error", reject);
});
}

// An async method returns a Promise object, which is compatible with then().catch() coding style.
main()
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion blob/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const zip = require("gulp-zip");
const version = require("./package.json").version;
const zipFileName = `azurestoragejs.blob-${version}.zip`;

gulp.task("zip", () => {
gulp.task("zip", async () => {
gulp
.src([
"browser/azure-storage.blob.js",
Expand Down
4 changes: 4 additions & 0 deletions blob/lib/BlobDownloadResponse.browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file is used as a shim of "BlobDownloadResponse" for some browser bundlers
// when trying to bundle "BlobDownloadResponse"
// "BlobDownloadResponse" class is only available in Node.js runtime
export const BlobDownloadResponse = 1;
Loading

0 comments on commit 09f6a7f

Please sign in to comment.