gcs-resumable-upload
Advanced tools
Comparing version 0.7.1 to 0.7.2
38
index.js
@@ -75,7 +75,4 @@ 'use strict' | ||
} else { | ||
self.createURI(function (err, uri) { | ||
self.createURI(function (err) { | ||
if (err) return self.destroy(err) | ||
self.uri = uri | ||
self.set({ uri: uri }) | ||
self.offset = 0 | ||
self.startUploading() | ||
@@ -95,2 +92,3 @@ }) | ||
Upload.prototype.createURI = function (callback) { | ||
var self = this | ||
var metadata = this.metadata | ||
@@ -121,8 +119,2 @@ | ||
if (this.encryption) { | ||
reqOpts.headers['x-goog-encryption-algorithm'] = 'AES256' | ||
reqOpts.headers['x-goog-encryption-key'] = this.encryption.key | ||
reqOpts.headers['x-goog-encryption-key-sha256'] = this.encryption.hash | ||
} | ||
if (this.predefinedAcl) { | ||
@@ -138,3 +130,9 @@ reqOpts.qs.predefinedAcl = this.predefinedAcl | ||
if (err) return callback(err) | ||
callback(null, resp.headers.location) | ||
var uri = resp.headers.location | ||
self.uri = uri | ||
self.set({ uri: uri }) | ||
self.offset = 0 | ||
callback(null, uri) | ||
}) | ||
@@ -170,6 +168,2 @@ } | ||
requestStream.on('complete', function (resp) { | ||
var body = resp.body | ||
self.emit('metadata', body) | ||
if (resp.statusCode < 200 || resp.statusCode > 299) { | ||
@@ -180,2 +174,4 @@ self.destroy(new Error('Upload failed')) | ||
self.emit('metadata', resp.body) | ||
self.deleteConfig() | ||
@@ -280,3 +276,3 @@ self.uncork() | ||
if (body && body.error) return callback(body.error) | ||
if (body && body.error) return callback(body.error, resp) | ||
@@ -302,2 +298,6 @@ var nonSuccess = Math.floor(resp.statusCode / 100) !== 2 // 200-299 status code | ||
requestStream.on('response', self.onResponse.bind(self)) | ||
requestStream.on('complete', function (resp) { | ||
var body = resp.body | ||
if (body && body.error) self.destroy(body.error) | ||
}) | ||
@@ -312,5 +312,9 @@ // this makes the response body come back in the response (weird?) | ||
Upload.prototype.restart = function () { | ||
var self = this | ||
this.numBytesWritten = 0 | ||
this.deleteConfig() | ||
this.startUploading() | ||
this.createURI(function (err) { | ||
if (err) return self.destroy(err) | ||
self.startUploading() | ||
}) | ||
} | ||
@@ -317,0 +321,0 @@ |
{ | ||
"name": "gcs-resumable-upload", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Upload a file to Google Cloud Storage with built-in resumable behavior", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16387
3
290