@google-cloud/storage
Advanced tools
+0
-0
@@ -0,0 +0,0 @@ # This is the official list of google-cloud-node authors for copyright purposes. |
+0
-0
@@ -0,0 +0,0 @@ # People who have agreed to one of the CLAs and can contribute patches. |
+0
-0
@@ -0,0 +0,0 @@ |
+3
-3
| { | ||
| "name": "@google-cloud/storage", | ||
| "version": "1.1.1", | ||
| "version": "1.2.0", | ||
| "author": "Google Inc.", | ||
@@ -58,5 +58,5 @@ "description": "Cloud Storage Client Library for Node.js", | ||
| "create-error-class": "^3.0.2", | ||
| "duplexify": "^3.2.0", | ||
| "duplexify": "^3.5.0", | ||
| "extend": "^3.0.0", | ||
| "gcs-resumable-upload": "^0.7.1", | ||
| "gcs-resumable-upload": "^0.8.0", | ||
| "hash-stream-validation": "^0.2.1", | ||
@@ -63,0 +63,0 @@ "is": "^3.0.1", |
+0
-0
@@ -0,0 +0,0 @@ # @google-cloud/storage ([GA][versioning]) |
+0
-0
@@ -0,0 +0,0 @@ /*! |
+567
-165
@@ -99,140 +99,3 @@ /*! | ||
| */ | ||
| create: true, | ||
| /** | ||
| * Delete the bucket. | ||
| * | ||
| * @resource [Buckets: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/delete} | ||
| * | ||
| * @param {function=} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this | ||
| * request. | ||
| * @param {object} callback.apiResponse - The full API response. | ||
| * | ||
| * @example | ||
| * bucket.delete(function(err, apiResponse) {}); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.delete().then(function(data) { | ||
| * var apiResponse = data[0]; | ||
| * }); | ||
| */ | ||
| delete: true, | ||
| /** | ||
| * Check if the bucket exists. | ||
| * | ||
| * @param {function} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this | ||
| * request. | ||
| * @param {boolean} callback.exists - Whether the bucket exists or not. | ||
| * | ||
| * @example | ||
| * bucket.exists(function(err, exists) {}); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.exists().then(function(data) { | ||
| * var exists = data[0]; | ||
| * }); | ||
| */ | ||
| exists: true, | ||
| /** | ||
| * Get a bucket if it exists. | ||
| * | ||
| * You may optionally use this to "get or create" an object by providing an | ||
| * object with `autoCreate` set to `true`. Any extra configuration that is | ||
| * normally required for the `create` method must be contained within this | ||
| * object as well. | ||
| * | ||
| * @param {options=} options - Configuration object. | ||
| * @param {boolean} options.autoCreate - Automatically create the object if | ||
| * it does not exist. Default: `false` | ||
| * | ||
| * @example | ||
| * bucket.get(function(err, bucket, apiResponse) { | ||
| * // `bucket.metadata` has been populated. | ||
| * }); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.get().then(function(data) { | ||
| * var bucket = data[0]; | ||
| * var apiResponse = data[1]; | ||
| * }); | ||
| */ | ||
| get: true, | ||
| /** | ||
| * Get the bucket's metadata. | ||
| * | ||
| * To set metadata, see {module:storage/bucket#setMetadata}. | ||
| * | ||
| * @resource [Buckets: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/get} | ||
| * | ||
| * @param {function=} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this | ||
| * request. | ||
| * @param {object} callback.metadata - The bucket's metadata. | ||
| * @param {object} callback.apiResponse - The full API response. | ||
| * | ||
| * @example | ||
| * bucket.getMetadata(function(err, metadata, apiResponse) {}); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.getMetadata().then(function(data) { | ||
| * var metadata = data[0]; | ||
| * var apiResponse = data[1]; | ||
| * }); | ||
| */ | ||
| getMetadata: true, | ||
| /** | ||
| * Set the bucket's metadata. | ||
| * | ||
| * @resource [Buckets: patch API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/patch} | ||
| * | ||
| * @param {object} metadata - The metadata you wish to set. | ||
| * @param {function=} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this | ||
| * request. | ||
| * @param {object} callback.apiResponse - The full API response. | ||
| * | ||
| * @example | ||
| * //- | ||
| * // Set website metadata field on the bucket. | ||
| * //- | ||
| * var metadata = { | ||
| * website: { | ||
| * mainPageSuffix: 'http://example.com', | ||
| * notFoundPage: 'http://example.com/404.html' | ||
| * } | ||
| * }; | ||
| * | ||
| * bucket.setMetadata(metadata, function(err, apiResponse) {}); | ||
| * | ||
| * //- | ||
| * // Enable versioning for your bucket. | ||
| * //- | ||
| * bucket.setMetadata({ | ||
| * versioning: { | ||
| * enabled: true | ||
| * } | ||
| * }, function(err, apiResponse) {}); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.setMetadata(metadata).then(function(data) { | ||
| * var apiResponse = data[0]; | ||
| * }); | ||
| */ | ||
| setMetadata: true | ||
| create: true | ||
| }; | ||
@@ -361,2 +224,6 @@ | ||
| * source files combined into. | ||
| * @param {object=} options - Configuration object. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function=} callback - The callback function. | ||
@@ -389,3 +256,3 @@ * @param {?error} callback.err - An error returned while making this request | ||
| */ | ||
| Bucket.prototype.combine = function(sources, destination, callback) { | ||
| Bucket.prototype.combine = function(sources, destination, options, callback) { | ||
| if (!is.array(sources) || sources.length < 2) { | ||
@@ -401,2 +268,7 @@ throw new Error('You must provide at least two source files.'); | ||
| if (is.fn(options)) { | ||
| callback = options; | ||
| options = {}; | ||
| } | ||
| sources = sources.map(convertToFile); | ||
@@ -436,3 +308,4 @@ destination = convertToFile(destination); | ||
| }) | ||
| } | ||
| }, | ||
| qs: options | ||
| }, function(err, resp) { | ||
@@ -469,2 +342,6 @@ if (err) { | ||
| * delivered for this channel. | ||
| * @param {object=} options - Configuration object. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function} callback - The callback function. | ||
@@ -497,3 +374,3 @@ * @param {?error} callback.err - An error returned while making this request | ||
| */ | ||
| Bucket.prototype.createChannel = function(id, config, callback) { | ||
| Bucket.prototype.createChannel = function(id, config, options, callback) { | ||
| var self = this; | ||
@@ -509,2 +386,7 @@ | ||
| if (is.fn(options)) { | ||
| callback = options; | ||
| options = {}; | ||
| } | ||
| this.request({ | ||
@@ -516,3 +398,4 @@ method: 'POST', | ||
| type: 'web_hook' | ||
| }, config) | ||
| }, config), | ||
| qs: options | ||
| }, function(err, apiResponse) { | ||
@@ -534,2 +417,39 @@ if (err) { | ||
| /** | ||
| * Delete the bucket. | ||
| * | ||
| * @resource [Buckets: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/delete} | ||
| * | ||
| * @param {object=} options - Configuration object. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function=} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this | ||
| * request. | ||
| * @param {object} callback.apiResponse - The full API response. | ||
| * | ||
| * @example | ||
| * bucket.delete(function(err, apiResponse) {}); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.delete().then(function(data) { | ||
| * var apiResponse = data[0]; | ||
| * }); | ||
| */ | ||
| Bucket.prototype.delete = function(options, callback) { | ||
| if (is.fn(options)) { | ||
| callback = options; | ||
| options = {}; | ||
| } | ||
| this.request({ | ||
| method: 'DELETE', | ||
| uri: '', | ||
| qs: options | ||
| }, callback || common.util.noop); | ||
| }; | ||
| /** | ||
| * Iterate over the bucket's files, calling `file.delete()` on each. | ||
@@ -555,2 +475,5 @@ * | ||
| * processed. | ||
| * @param {boolean} query.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function} callback - The callback function. | ||
@@ -613,3 +536,3 @@ * @param {?error|?error[]} callback.err - An API error or array of errors from | ||
| function deleteFile(file, callback) { | ||
| file.delete(function(err) { | ||
| file.delete(query, function(err) { | ||
| if (err) { | ||
@@ -642,3 +565,191 @@ if (query.force) { | ||
| /** | ||
| * Delete one or more labels from this bucket. | ||
| * | ||
| * @param {string=|string[]=} labels - The labels to delete. If no labels are | ||
| * provided, all of the labels are removed. | ||
| * @param {function} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this request. | ||
| * @param {object} callback.metadata - The bucket's metadata. | ||
| * | ||
| * @example | ||
| * //- | ||
| * // Delete all of the labels from this bucket. | ||
| * //- | ||
| * bucket.deleteLabels(function(err, metadata) {}); | ||
| * | ||
| * //- | ||
| * // Delete a single label. | ||
| * //- | ||
| * bucket.deleteLabels('labelone', function(err, metadata) {}); | ||
| * | ||
| * //- | ||
| * // Delete a specific set of labels. | ||
| * //- | ||
| * bucket.deleteLabels([ | ||
| * 'labelone', | ||
| * 'labeltwo' | ||
| * ], function(err, metadata) {}); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.deleteLabels().then(function(data) { | ||
| * var metadata = data[0]; | ||
| * }); | ||
| */ | ||
| Bucket.prototype.deleteLabels = function(labels, callback) { | ||
| var self = this; | ||
| if (is.fn(labels)) { | ||
| callback = labels; | ||
| labels = []; | ||
| } | ||
| labels = arrify(labels); | ||
| if (labels.length === 0) { | ||
| this.getLabels(function(err, labels) { | ||
| if (err) { | ||
| callback(err); | ||
| return; | ||
| } | ||
| deleteLabels(Object.keys(labels)); | ||
| }); | ||
| } else { | ||
| deleteLabels(labels); | ||
| } | ||
| function deleteLabels(labels) { | ||
| var nullLabelMap = labels.reduce(function(nullLabelMap, labelKey) { | ||
| nullLabelMap[labelKey] = null; | ||
| return nullLabelMap; | ||
| }, {}); | ||
| self.setLabels(nullLabelMap, callback); | ||
| } | ||
| }; | ||
| /** | ||
| * <div class="notice"> | ||
| * <strong>Early Access Testers Only</strong> | ||
| * <p> | ||
| * This feature is not yet widely-available. | ||
| * </p> | ||
| * </div> | ||
| * | ||
| * Disable `requesterPays` functionality from this bucket. | ||
| * | ||
| * @param {function=} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this request. | ||
| * @param {object} callback.apiResponse - The full API response. | ||
| * | ||
| * @example | ||
| * bucket.disableRequesterPays(function(err) { | ||
| * if (!err) { | ||
| * // requesterPays functionality disabled successfully. | ||
| * } | ||
| * }); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.disableRequesterPays().then(function(data) { | ||
| * var apiResponse = data[0]; | ||
| * }); | ||
| */ | ||
| Bucket.prototype.disableRequesterPays = function(callback) { | ||
| this.setMetadata({ | ||
| billing: { | ||
| requesterPays: false | ||
| } | ||
| }, callback || common.util.noop); | ||
| }; | ||
| /** | ||
| * <div class="notice"> | ||
| * <strong>Early Access Testers Only</strong> | ||
| * <p> | ||
| * This feature is not yet widely-available. | ||
| * </p> | ||
| * </div> | ||
| * | ||
| * Enable `requesterPays` functionality for this bucket. This enables you, the | ||
| * bucket owner, to have the requesting user assume the charges for the access | ||
| * to your bucket and its contents. | ||
| * | ||
| * @param {function=} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this request. | ||
| * @param {object} callback.apiResponse - The full API response. | ||
| * | ||
| * @example | ||
| * bucket.enableRequesterPays(function(err) { | ||
| * if (!err) { | ||
| * // requesterPays functionality enabled successfully. | ||
| * } | ||
| * }); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.enableRequesterPays().then(function(data) { | ||
| * var apiResponse = data[0]; | ||
| * }); | ||
| */ | ||
| Bucket.prototype.enableRequesterPays = function(callback) { | ||
| this.setMetadata({ | ||
| billing: { | ||
| requesterPays: true | ||
| } | ||
| }, callback || common.util.noop); | ||
| }; | ||
| /** | ||
| * Check if the bucket exists. | ||
| * | ||
| * @param {options=} options - Configuration object. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this | ||
| * request. | ||
| * @param {boolean} callback.exists - Whether the bucket exists or not. | ||
| * | ||
| * @example | ||
| * bucket.exists(function(err, exists) {}); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.exists().then(function(data) { | ||
| * var exists = data[0]; | ||
| * }); | ||
| */ | ||
| Bucket.prototype.exists = function(options, callback) { | ||
| if (is.fn(options)) { | ||
| callback = options; | ||
| options = {}; | ||
| } | ||
| options = options || {}; | ||
| this.get(options, function(err) { | ||
| if (err) { | ||
| if (err.code === 404) { | ||
| callback(null, false); | ||
| } else { | ||
| callback(err); | ||
| } | ||
| return; | ||
| } | ||
| callback(null, true); | ||
| }); | ||
| }; | ||
| /** | ||
| * Create a File object. See {module:storage/file} to see how to handle | ||
@@ -667,2 +778,80 @@ * the different use cases you may have. | ||
| /** | ||
| * Get a bucket if it exists. | ||
| * | ||
| * You may optionally use this to "get or create" an object by providing an | ||
| * object with `autoCreate` set to `true`. Any extra configuration that is | ||
| * normally required for the `create` method must be contained within this | ||
| * object as well. | ||
| * | ||
| * @param {options=} options - Configuration object. | ||
| * @param {boolean} options.autoCreate - Automatically create the object if | ||
| * it does not exist. Default: `false` | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * | ||
| * @example | ||
| * bucket.get(function(err, bucket, apiResponse) { | ||
| * // `bucket.metadata` has been populated. | ||
| * }); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.get().then(function(data) { | ||
| * var bucket = data[0]; | ||
| * var apiResponse = data[1]; | ||
| * }); | ||
| */ | ||
| Bucket.prototype.get = function(options, callback) { | ||
| var self = this; | ||
| if (is.fn(options)) { | ||
| callback = options; | ||
| options = {}; | ||
| } | ||
| options = options || {}; | ||
| var autoCreate = options.autoCreate; | ||
| delete options.autoCreate; | ||
| function onCreate(err, bucket, apiResponse) { | ||
| if (err) { | ||
| if (err.code === 409) { | ||
| self.get(options, callback); | ||
| return; | ||
| } | ||
| callback(err, null, apiResponse); | ||
| return; | ||
| } | ||
| callback(null, bucket, apiResponse); | ||
| } | ||
| this.getMetadata(options, function(err, metadata) { | ||
| if (err) { | ||
| if (err.code === 404 && autoCreate) { | ||
| var args = []; | ||
| if (!is.empty(options)) { | ||
| args.push(options); | ||
| } | ||
| args.push(onCreate); | ||
| self.create.apply(self, args); | ||
| return; | ||
| } | ||
| callback(err, null, metadata); | ||
| return; | ||
| } | ||
| callback(null, self, metadata); | ||
| }); | ||
| }; | ||
| /** | ||
| * Get File objects for the files currently in the bucket. | ||
@@ -687,2 +876,5 @@ * | ||
| * representing part of the larger set of results to view. | ||
| * @param {boolean} query.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {boolean} query.versions - If true, returns File objects scoped to | ||
@@ -813,2 +1005,99 @@ * their versions. | ||
| /** | ||
| * Get the labels from this bucket. | ||
| * | ||
| * @param {object=} options - Configuration object. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this request. | ||
| * @param {object} callback.labels - The labels currently set on this bucket. | ||
| * | ||
| * @example | ||
| * bucket.getLabels(function(err, labels) { | ||
| * if (err) { | ||
| * // Error handling omitted. | ||
| * } | ||
| * | ||
| * // labels = { | ||
| * // label: 'labelValue', | ||
| * // ... | ||
| * // } | ||
| * }); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.getLabels().then(function(data) { | ||
| * var labels = data[0]; | ||
| * }); | ||
| */ | ||
| Bucket.prototype.getLabels = function(options, callback) { | ||
| if (is.fn(options)) { | ||
| callback = options; | ||
| options = {}; | ||
| } | ||
| this.getMetadata(options, function(err, metadata) { | ||
| if (err) { | ||
| callback(err); | ||
| return; | ||
| } | ||
| callback(null, metadata.labels || {}); | ||
| }); | ||
| }; | ||
| /** | ||
| * Get the bucket's metadata. | ||
| * | ||
| * To set metadata, see {module:storage/bucket#setMetadata}. | ||
| * | ||
| * @resource [Buckets: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/get} | ||
| * | ||
| * @param {object=} options - Configuration object. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function=} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this | ||
| * request. | ||
| * @param {object} callback.metadata - The bucket's metadata. | ||
| * @param {object} callback.apiResponse - The full API response. | ||
| * | ||
| * @example | ||
| * bucket.getMetadata(function(err, metadata, apiResponse) {}); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.getMetadata().then(function(data) { | ||
| * var metadata = data[0]; | ||
| * var apiResponse = data[1]; | ||
| * }); | ||
| */ | ||
| Bucket.prototype.getMetadata = function(options, callback) { | ||
| var self = this; | ||
| if (is.fn(options)) { | ||
| callback = options; | ||
| options = {}; | ||
| } | ||
| this.request({ | ||
| uri: '', | ||
| qs: options | ||
| }, function(err, resp) { | ||
| if (err) { | ||
| callback(err, null, resp); | ||
| return; | ||
| } | ||
| self.metadata = resp; | ||
| callback(null, self.metadata, resp); | ||
| }); | ||
| }; | ||
| /** | ||
| * Make the bucket listing private. | ||
@@ -836,2 +1125,5 @@ * | ||
| * private until all files have been processed. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function} callback - The callback function. | ||
@@ -904,23 +1196,11 @@ * @param {?error} callback.err - An error returned while making this request | ||
| // You aren't allowed to set both predefinedAcl & acl properties on a bucket | ||
| // so acl must explicitly be nullified. | ||
| var metadata = { | ||
| if (options.userProject) { | ||
| query.userProject = options.userProject; | ||
| } | ||
| self.setMetadata({ | ||
| // You aren't allowed to set both predefinedAcl & acl properties on a | ||
| // bucket so acl must explicitly be nullified. | ||
| acl: null | ||
| }; | ||
| self.request({ | ||
| method: 'PATCH', | ||
| uri: '', | ||
| qs: query, | ||
| json: metadata | ||
| }, function(err, resp) { | ||
| if (err) { | ||
| done(err); | ||
| return; | ||
| } | ||
| self.metadata = resp; | ||
| done(); | ||
| }); | ||
| }, query, done); | ||
| } | ||
@@ -1053,2 +1333,118 @@ | ||
| /** | ||
| * Set labels on the bucket. | ||
| * | ||
| * This makes an underlying call to {module:storage/bucket#setMetadata}, which | ||
| * is a PATCH request. This means an individual label can be overwritten, but | ||
| * unmentioned labels will not be touched. | ||
| * | ||
| * @param {type} labels - Labels to set on the bucket. | ||
| * @param {object=} options - Configuration object. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function=} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this request. | ||
| * @param {object} callback.metadata - The bucket's metadata. | ||
| * | ||
| * @example | ||
| * var labels = { | ||
| * labelone: 'labelonevalue', | ||
| * labeltwo: 'labeltwovalue' | ||
| * }; | ||
| * | ||
| * bucket.setLabels(labels, function(err, metadata) { | ||
| * if (!err) { | ||
| * // Labels set successfully. | ||
| * } | ||
| * }); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.setLabels(labels).then(function(data) { | ||
| * var metadata = data[0]; | ||
| * }); | ||
| */ | ||
| Bucket.prototype.setLabels = function(labels, options, callback) { | ||
| if (is.fn(options)) { | ||
| callback = options; | ||
| options = {}; | ||
| } | ||
| callback = callback || common.util.noop; | ||
| this.setMetadata({labels}, options, callback); | ||
| }; | ||
| /** | ||
| * Set the bucket's metadata. | ||
| * | ||
| * @resource [Buckets: patch API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/patch} | ||
| * | ||
| * @param {object} metadata - The metadata you wish to set. | ||
| * @param {object=} options - Configuration object. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function=} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this request. | ||
| * @param {object} callback.apiResponse - The full API response. | ||
| * | ||
| * @example | ||
| * //- | ||
| * // Set website metadata field on the bucket. | ||
| * //- | ||
| * var metadata = { | ||
| * website: { | ||
| * mainPageSuffix: 'http://example.com', | ||
| * notFoundPage: 'http://example.com/404.html' | ||
| * } | ||
| * }; | ||
| * | ||
| * bucket.setMetadata(metadata, function(err, apiResponse) {}); | ||
| * | ||
| * //- | ||
| * // Enable versioning for your bucket. | ||
| * //- | ||
| * bucket.setMetadata({ | ||
| * versioning: { | ||
| * enabled: true | ||
| * } | ||
| * }, function(err, apiResponse) {}); | ||
| * | ||
| * //- | ||
| * // If the callback is omitted, we'll return a Promise. | ||
| * //- | ||
| * bucket.setMetadata(metadata).then(function(data) { | ||
| * var apiResponse = data[0]; | ||
| * }); | ||
| */ | ||
| Bucket.prototype.setMetadata = function(metadata, options, callback) { | ||
| var self = this; | ||
| if (is.fn(options)) { | ||
| callback = options; | ||
| options = {}; | ||
| } | ||
| callback = callback || common.util.noop; | ||
| this.request({ | ||
| method: 'PATCH', | ||
| uri: '', | ||
| json: metadata, | ||
| qs: options | ||
| }, function(err, resp) { | ||
| if (err) { | ||
| callback(err, resp); | ||
| return; | ||
| } | ||
| self.metadata = resp; | ||
| callback(null, resp); | ||
| }); | ||
| }; | ||
| /** | ||
| * Upload a file to the bucket. This is a convenience method that wraps | ||
@@ -1114,2 +1510,5 @@ * {module:storage/file#createWriteStream}. | ||
| * upload. See {module:storage/file#createResumableUpload}. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {string|boolean} options.validation - Possible values: `"md5"`, | ||
@@ -1300,2 +1699,5 @@ * `"crc32c"`, or `false`. By default, data integrity is validated with an | ||
| * @param {boolean} options.public - Make files public. | ||
| * @param {boolean} options.userProject - If this bucket has `requesterPays` | ||
| * functionality enabled (see {module:storage/bucket#enableRequesterPays}), | ||
| * set this value to the project which should be billed for this operation. | ||
| * @param {function} callback - The callback function. | ||
@@ -1308,3 +1710,3 @@ */ | ||
| this.getFiles(function(err, files) { | ||
| this.getFiles(options, function(err, files) { | ||
| if (err) { | ||
@@ -1319,3 +1721,3 @@ callback(err); | ||
| } else if (options.private) { | ||
| file.makePrivate(processedCallback); | ||
| file.makePrivate(options, processedCallback); | ||
| } | ||
@@ -1322,0 +1724,0 @@ |
+0
-0
@@ -0,0 +0,0 @@ /*! |
+0
-0
@@ -0,0 +0,0 @@ /*! |
+10
-1
@@ -203,2 +203,4 @@ /*! | ||
| * @param {boolean} metadata.regional - Specify the storage class as Regional. | ||
| * @param {boolean} metadata.requesterPays - **Early Access Testers Only** | ||
| * Enable billing the requesting user's project. | ||
| * @param {function} callback - The callback function. | ||
@@ -260,3 +262,3 @@ * @param {?error} callback.err - An error returned while making this request | ||
| var body = extend(metadata, { | ||
| var body = extend({}, metadata, { | ||
| name: name | ||
@@ -280,2 +282,9 @@ }); | ||
| if (body.requesterPays) { | ||
| body.billing = { | ||
| requesterPays: body.requesterPays | ||
| }; | ||
| delete body.requesterPays; | ||
| } | ||
| this.request({ | ||
@@ -282,0 +291,0 @@ method: 'POST', |
Sorry, the diff of this file is too big to display
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
176280
6.15%4746
10.14%30
-23.08%0
-100%+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated