Socket
Socket
Sign inDemoInstall

@google-cloud/storage

Package Overview
Dependencies
Maintainers
1
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/storage - npm Package Compare versions

Comparing version 6.5.1 to 6.5.2

40

build/src/resumable-upload.js

@@ -374,3 +374,3 @@ "use strict";

let expectedUploadSize = undefined;
// Set `expectedUploadSize` to `contentLength` if available
// Set `expectedUploadSize` to `contentLength - this.numBytesWritten`, if available
if (typeof this.contentLength === 'number') {

@@ -417,7 +417,24 @@ expectedUploadSize = this.contentLength - this.numBytesWritten;

// If using multiple chunk upload, set appropriate header
if (multiChunkMode && expectedUploadSize) {
// The '-1' is because the ending byte is inclusive in the request.
const endingByte = expectedUploadSize + this.numBytesWritten - 1;
headers['Content-Length'] = expectedUploadSize;
headers['Content-Range'] = `bytes ${this.offset}-${endingByte}/${this.contentLength}`;
if (multiChunkMode) {
// We need to know how much data is available upstream to set the `Content-Range` header.
const oneChunkIterator = this.upstreamIterator(expectedUploadSize, true);
const { value } = await oneChunkIterator.next();
const bytesToUpload = value.chunk.byteLength;
// Important: we want to know if the upstream has ended and the queue is empty before
// unshifting data back into the queue. This way we will know if this is the last request or not.
const isLastChunkOfUpload = !(await this.waitForNextChunk());
// Important: put the data back in the queue for the actual upload iterator
this.unshiftChunkBuffer(value.chunk);
let totalObjectSize = this.contentLength;
if (typeof this.contentLength !== 'number' && isLastChunkOfUpload) {
// Let's let the server know this is the last chunk since
// we didn't know the content-length beforehand.
totalObjectSize = bytesToUpload + this.numBytesWritten;
}
// `- 1` as the ending byte is inclusive in the request.
const endingByte = bytesToUpload + this.numBytesWritten - 1;
// `Content-Length` for multiple chunk uploads is the size of the chunk,
// not the overall object
headers['Content-Length'] = bytesToUpload;
headers['Content-Range'] = `bytes ${this.offset}-${endingByte}/${totalObjectSize}`;
}

@@ -486,7 +503,8 @@ else {

else if (!this.isSuccessfulResponse(resp.status)) {
const err = {
code: resp.status,
name: 'Upload failed',
message: 'Upload failed',
};
const err = new Error('Upload failed');
err.code = resp.status;
err.name = 'Upload failed';
if (resp === null || resp === void 0 ? void 0 : resp.data) {
err.errors = [resp === null || resp === void 0 ? void 0 : resp.data];
}
this.destroy(err);

@@ -493,0 +511,0 @@ }

{
"name": "@google-cloud/storage",
"description": "Cloud Storage Client Library for Node.js",
"version": "6.5.1",
"version": "6.5.2",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "author": "Google Inc.",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc