google-cloud-bucket
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="0.0.2"></a> | ||
## [0.0.2](https://github.com/nicolasdao/google-cloud-bucket/compare/v0.0.1...v0.0.2) (2018-11-11) | ||
### Features | ||
* Add support for throwing an exception if access denied ([aa76923](https://github.com/nicolasdao/google-cloud-bucket/commit/aa76923)) | ||
<a name="0.0.1"></a> | ||
@@ -7,0 +17,0 @@ ## 0.0.1 (2018-11-10) |
21
index.js
@@ -29,3 +29,11 @@ /** | ||
Authorization: `Bearer ${token}` | ||
}, content) | ||
}, content).then(({ status, data }) => { | ||
if (status > 299) { | ||
const message = ((data || {}).error || {}).message || JSON.stringify(data || {}) | ||
let e = new Error(message) | ||
e.code = status | ||
throw e | ||
} | ||
return { status, data } | ||
}) | ||
}) | ||
@@ -43,3 +51,12 @@ | ||
const retryPutObject = (object, filePath, options={}) => retry(() => putObject(object, filePath), () => true, { ignoreFailure: true, retryInterval: 800 }) | ||
const retryPutObject = (object, filePath, options={}) => retry( | ||
() => putObject(object, filePath), | ||
() => true, | ||
err => { | ||
if (err && err.message && err.message.indexOf('access') > 0) | ||
return false | ||
else | ||
return true | ||
}, | ||
{ ignoreFailure: true, retryInterval: 800 }) | ||
.catch(e => { | ||
@@ -46,0 +63,0 @@ if (options.retryCatch) |
{ | ||
"name": "google-cloud-bucket", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Nodejs package to add objects to a Google Cloud Bucket.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -51,3 +51,3 @@ # Google Cloud Bucket · [![NPM](https://img.shields.io/npm/v/google-cloud-bucket.svg?style=flat)](https://www.npmjs.com/package/google-cloud-bucket) [![Tests](https://travis-ci.org/nicolasdao/google-cloud-bucket.svg?branch=master)](https://travis-ci.org/nicolasdao/google-cloud-bucket) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![Neap](https://neap.co/img/made_by_neap.svg)](#this-is-what-we-re-up-to) | ||
client.putObject(task_01, 'your-bucket/a-path/filename.json').then(res => console.log(res)) | ||
client.putObject(someObject, 'your-bucket/a-path/filename.json').then(res => console.log(res)) | ||
``` | ||
@@ -54,0 +54,0 @@ |
24546
482