@azure/storage-blob 12.2.1-alpha.20200909.1 → 12.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # Release History
2
2
 
3
- ## 12.2.1 (Unreleased)
3
+ ## 12.2.1 (2020-09-17)
4
4
 
5
+ - Bug fix - Fixes an issue where`BlockBlobClient.uploadStream()` will give an "Invalid Verb" error when keep-alive is enabled. Fixed bug [11187](https://github.com/Azure/azure-sdk-for-js/issues/11187).
5
6
 
6
7
  ## 12.2.0 (2020-09-08)
7
8
 
package/README.md CHANGED
@@ -14,7 +14,7 @@ Use the client libraries in this package to:
14
14
 
15
15
  [Source code](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob) |
16
16
  [Package (npm)](https://www.npmjs.com/package/@azure/storage-blob/) |
17
- [API Reference Documentation](https://docs.microsoft.com/en-us/javascript/api/overview/azure/storage-overview) |
17
+ [API Reference Documentation](https://docs.microsoft.com/javascript/api/@azure/storage-blob) |
18
18
  [Product documentation](https://docs.microsoft.com/azure/storage/blobs/storage-blobs-overview) |
19
19
  [Samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob/samples) |
20
20
  [Azure Storage Blob REST APIs](https://docs.microsoft.com/rest/api/storageservices/blob-service-rest-api)
@@ -434,7 +434,9 @@ async function main() {
434
434
  // Get blob content from position 0 to the end
435
435
  // In Node.js, get downloaded data by accessing downloadBlockBlobResponse.readableStreamBody
436
436
  const downloadBlockBlobResponse = await blobClient.download();
437
- const downloaded = (await streamToBuffer(downloadBlockBlobResponse.readableStreamBody)).toString();
437
+ const downloaded = (
438
+ await streamToBuffer(downloadBlockBlobResponse.readableStreamBody)
439
+ ).toString();
438
440
  console.log("Downloaded blob content:", downloaded);
439
441
 
440
442
  // [Node.js only] A helper method used to read a Node.js readable stream into a Buffer
package/dist/index.js CHANGED
@@ -11436,7 +11436,7 @@ function extractConnectionStringParts(connectionString) {
11436
11436
  url: blobEndpoint,
11437
11437
  accountName: accountName,
11438
11438
  accountKey: accountKey,
11439
- proxyUri: proxyUri,
11439
+ proxyUri: proxyUri
11440
11440
  };
11441
11441
  }
11442
11442
  else {
@@ -11721,7 +11721,7 @@ function getAccountNameFromUrl(url) {
11721
11721
  }
11722
11722
  else {
11723
11723
  // Custom domain case: "https://customdomain.com/containername/blob".
11724
- accountName = '';
11724
+ accountName = "";
11725
11725
  }
11726
11726
  return accountName;
11727
11727
  }
@@ -11733,7 +11733,7 @@ function isIpEndpointStyle(parsedUrl) {
11733
11733
  if (parsedUrl.getHost() == undefined) {
11734
11734
  return false;
11735
11735
  }
11736
- var host = parsedUrl.getHost() + (parsedUrl.getPort() == undefined ? '' : ':' + parsedUrl.getPort());
11736
+ var host = parsedUrl.getHost() + (parsedUrl.getPort() == undefined ? "" : ":" + parsedUrl.getPort());
11737
11737
  // Case 1: Ipv6, use a broad regex to find out candidates whose host contains two ':'.
11738
11738
  // Case 2: localhost(:port), use broad regex to match port part.
11739
11739
  // Case 3: Ipv4, use broad regex which just check if host contains Ipv4.
@@ -15128,7 +15128,7 @@ var StorageSharedKeyCredential = /** @class */ (function (_super) {
15128
15128
  * regenerated.
15129
15129
  */
15130
15130
  var packageName = "azure-storage-blob";
15131
- var packageVersion = "12.2.0";
15131
+ var packageVersion = "12.2.1";
15132
15132
  var StorageClientContext = /** @class */ (function (_super) {
15133
15133
  tslib.__extends(StorageClientContext, _super);
15134
15134
  /**
@@ -15150,7 +15150,7 @@ var StorageClientContext = /** @class */ (function (_super) {
15150
15150
  options.userAgent = packageName + "/" + packageVersion + " " + defaultUserAgent;
15151
15151
  }
15152
15152
  _this = _super.call(this, undefined, options) || this;
15153
- _this.version = '2019-12-12';
15153
+ _this.version = "2019-12-12";
15154
15154
  _this.baseUri = "{url}";
15155
15155
  _this.requestContentType = "application/json; charset=utf-8";
15156
15156
  _this.url = url;
@@ -15670,9 +15670,18 @@ var BuffersStream = /** @class */ (function (_super) {
15670
15670
  var _this = _super.call(this, options) || this;
15671
15671
  _this.buffers = buffers;
15672
15672
  _this.byteLength = byteLength;
15673
- _this.byteOffset = 0;
15673
+ _this.byteOffsetInCurrentBuffer = 0;
15674
15674
  _this.bufferIndex = 0;
15675
15675
  _this.pushedBytesLength = 0;
15676
+ // check byteLength is no larger than buffers[] total length
15677
+ var buffersLength = 0;
15678
+ for (var _i = 0, _a = _this.buffers; _i < _a.length; _i++) {
15679
+ var buf = _a[_i];
15680
+ buffersLength += buf.byteLength;
15681
+ }
15682
+ if (buffersLength < _this.byteLength) {
15683
+ throw new Error("Data size shouldn't be larger than the total length of buffers.");
15684
+ }
15676
15685
  return _this;
15677
15686
  }
15678
15687
  /**
@@ -15691,19 +15700,31 @@ var BuffersStream = /** @class */ (function (_super) {
15691
15700
  var outBuffers = [];
15692
15701
  var i = 0;
15693
15702
  while (i < size && this.pushedBytesLength < this.byteLength) {
15694
- var remaining = this.buffers[this.bufferIndex].byteLength - this.byteOffset;
15703
+ // The last buffer may be longer than the data it contains.
15704
+ var remainingDataInAllBuffers = this.byteLength - this.pushedBytesLength;
15705
+ var remainingCapacityInThisBuffer = this.buffers[this.bufferIndex].byteLength - this.byteOffsetInCurrentBuffer;
15706
+ var remaining = Math.min(remainingCapacityInThisBuffer, remainingDataInAllBuffers);
15695
15707
  if (remaining > size - i) {
15696
- var end = this.byteOffset + size - i;
15697
- outBuffers.push(this.buffers[this.bufferIndex].slice(this.byteOffset, end));
15708
+ // chunkSize = size - i
15709
+ var end = this.byteOffsetInCurrentBuffer + size - i;
15710
+ outBuffers.push(this.buffers[this.bufferIndex].slice(this.byteOffsetInCurrentBuffer, end));
15698
15711
  this.pushedBytesLength += size - i;
15699
- this.byteOffset = end;
15712
+ this.byteOffsetInCurrentBuffer = end;
15700
15713
  i = size;
15701
15714
  break;
15702
15715
  }
15703
15716
  else {
15704
- outBuffers.push(this.buffers[this.bufferIndex].slice(this.byteOffset));
15705
- this.byteOffset = 0;
15706
- this.bufferIndex++;
15717
+ // chunkSize = remaining
15718
+ var end = this.byteOffsetInCurrentBuffer + remaining;
15719
+ outBuffers.push(this.buffers[this.bufferIndex].slice(this.byteOffsetInCurrentBuffer, end));
15720
+ if (remaining === remainingCapacityInThisBuffer) {
15721
+ // this.buffers[this.bufferIndex] used up, shift to next one
15722
+ this.byteOffsetInCurrentBuffer = 0;
15723
+ this.bufferIndex++;
15724
+ }
15725
+ else {
15726
+ this.byteOffsetInCurrentBuffer = end;
15727
+ }
15707
15728
  this.pushedBytesLength += remaining;
15708
15729
  i += remaining;
15709
15730
  }
@@ -15747,7 +15768,7 @@ var PooledBuffer = /** @class */ (function () {
15747
15768
  */
15748
15769
  this.buffers = [];
15749
15770
  this.capacity = capacity;
15750
- this._size = capacity;
15771
+ this._size = 0;
15751
15772
  // allocate
15752
15773
  var bufferNum = Math.ceil(capacity / maxBufferLength);
15753
15774
  for (var i = 0; i < bufferNum; i++) {