gcs-resumable-upload
Advanced tools
Comparing version 0.2.1 to 0.2.2
18
index.js
@@ -7,3 +7,3 @@ 'use strict' | ||
var Pumpify = require('pumpify') | ||
var request = require('request') | ||
var request = require('request').defaults({ json: true }) | ||
var StreamEvents = require('stream-events') | ||
@@ -127,4 +127,2 @@ var through = require('through2') | ||
try { body = JSON.parse(body) } catch (e) {} | ||
self.emit('response', resp, body) | ||
@@ -216,7 +214,11 @@ | ||
request(authorizedReqOpts, function (err, resp, body) { | ||
var error = err | ||
try { body = JSON.parse(body) } catch (e) {} | ||
if (resp.statusCode < 200 || resp.statusCode > 299) error = new Error(resp.body) | ||
if (body && body.error) error = body.error | ||
if (error) return callback(error) | ||
if (err) return callback(err) | ||
if (body && body.error) return callback(body.error) | ||
var nonSuccess = Math.floor(resp.statusCode / 100) !== 2 // 200-299 status code | ||
if (nonSuccess && resp.statusCode !== RESUMABLE_INCOMPLETE_STATUS_CODE) { | ||
return callback(new Error(body)) | ||
} | ||
callback(null, resp, body) | ||
@@ -223,0 +225,0 @@ }) |
{ | ||
"name": "gcs-resumable-upload", | ||
"version": "0.2.1", | ||
"version": "0.2.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
13158