google-cloud-bucket
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="0.3.1"></a> | ||
## [0.3.1](https://github.com/nicolasdao/google-cloud-bucket/compare/v0.3.0...v0.3.1) (2018-12-05) | ||
<a name="0.3.0"></a> | ||
@@ -7,0 +12,0 @@ # [0.3.0](https://github.com/nicolasdao/google-cloud-bucket/compare/v0.2.1...v0.3.0) (2018-12-05) |
36
index.js
@@ -31,11 +31,2 @@ /** | ||
}) | ||
.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 } | ||
}) | ||
@@ -62,26 +53,27 @@ const _getBucketAndPathname = (filePath, options={}) => { | ||
const putObject = (object, filePath, options) => getToken(auth).then(token => gcp.insert(object, filePath, token, options)) | ||
const getObject = (bucket, filePath) => getToken(auth).then(token => gcp.get(bucket, filePath, token)) | ||
const getBucket = (bucket) => getToken(auth).then(token => gcp.config.get(bucket, token)) | ||
const isBucketPublic = (bucket) => getToken(auth).then(token => gcp.config.isBucketPublic(bucket, token)) | ||
const updateConfig = (bucket, config={}) => getToken(auth).then(token => gcp.config.update(bucket, config, token)) | ||
const putObject = (object, filePath, options) => getToken(auth).then(token => gcp.insert(object, filePath, token, options)).then(({ data }) => data) | ||
const getObject = (bucket, filePath) => getToken(auth).then(token => gcp.get(bucket, filePath, token)).then(({ data }) => data) | ||
const getBucket = (bucket) => getToken(auth).then(token => gcp.config.get(bucket, token)).then(({ data }) => data) | ||
const isBucketPublic = (bucket) => getToken(auth).then(token => gcp.config.isBucketPublic(bucket, token)).then(({ data }) => data) | ||
const updateConfig = (bucket, config={}) => getToken(auth).then(token => gcp.config.update(bucket, config, token)).then(({ data }) => data) | ||
const addPublicAccess = filePath => getToken(auth).then(token => { | ||
const { bucket, file } = _getBucketAndPathname(filePath, { ignoreMissingFile: true }) | ||
return gcp.addPublicAccess(bucket, file, token) | ||
}) | ||
}).then(({ data }) => data) | ||
const removePublicAccess = filePath => getToken(auth).then(token => { | ||
const { bucket, file } = _getBucketAndPathname(filePath, { ignoreMissingFile: true }) | ||
return gcp.removePublicAccess(bucket, file, token) | ||
}) | ||
}).then(({ data }) => data) | ||
const retryPutObject = (object, filePath, options={}) => _retryFn(() => putObject(object, filePath, options), options) | ||
.then(res => { | ||
.then(data => { | ||
if (options.public) | ||
return addPublicAccess(filePath).then(({ data:{ uri } }) => { | ||
if (res && res.data) | ||
res.data.uri = uri | ||
return res | ||
return addPublicAccess(filePath).then(({ uri }) => { | ||
if (data) | ||
data.uri = uri | ||
return data | ||
}) | ||
return res | ||
return data | ||
}) | ||
const retryGetObject = (filePath, options={}) => Promise.resolve(null).then(() => { | ||
@@ -88,0 +80,0 @@ const { bucket, file } = _getBucketAndPathname(filePath) |
{ | ||
"name": "google-cloud-bucket", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Nodejs package to add objects to a Google Cloud Bucket.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -90,8 +90,3 @@ /** | ||
const objectViewerBinding = bindings.find(b => b && b.role == 'roles/storage.objectViewer') | ||
if (!objectViewerBinding) | ||
bindings.push({ | ||
role: 'roles/storage.objectViewer', | ||
members: ['allUsers'] | ||
}) | ||
return !objectViewerBinding || (objectViewerBinding.members || []).some(m => m == 'allUsers') | ||
return objectViewerBinding && (objectViewerBinding.members || []).some(m => m == 'allUsers') | ||
}) | ||
@@ -98,0 +93,0 @@ }) |
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
47529
941