Skip to content

Commit 8178bcd

Browse files
docs: show how to use versioning
1 parent 8b3e45d commit 8178bcd

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

lib/storage/bucket.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,16 @@ Bucket.prototype.file = function(name, options) {
368368
* bucket.getFiles({
369369
* maxResults: 5
370370
* }, function(err, files, nextQuery, apiResponse) {});
371+
*
372+
* //-
373+
* // If your bucket has versioning enabled, you can get all of your files
374+
* // scoped to their generation.
375+
* //-
376+
* bucket.getFiles({
377+
* versions: true
378+
* }, function(err, files, nextQuery, apiResponse) {
379+
* // Each file is scoped to its generation.
380+
* });
371381
*/
372382
Bucket.prototype.getFiles = function(query, callback) {
373383
var self = this;
@@ -652,6 +662,15 @@ Bucket.prototype.makePublic = function(options, callback) {
652662
* notFoundPage: 'http://example.com/404.html'
653663
* }
654664
* }, function(err, metadata, apiResponse) {});
665+
*
666+
* //-
667+
* // Enable versioning for your bucket.
668+
* //-
669+
* bucket.setMetadata({
670+
* versioning: {
671+
* enabled: true
672+
* }
673+
* }, function(err, metadata, apiResponse) {});
655674
*/
656675
Bucket.prototype.setMetadata = function(metadata, callback) {
657676
var that = this;

lib/storage/file.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ var STORAGE_UPLOAD_BASE_URL = 'https://www.googleapis.com/upload/storage/v1/b';
5454
* @param {module:storage/bucket} bucket - The Bucket instance this file is
5555
* attached to.
5656
* @param {string} name - The name of the remote file.
57-
* @param {object=} metadata - Metadata to set on the object. This is useful
58-
* when you are creating a file for the first time, to prevent making an
59-
* extra call to `setMetadata`.
57+
* @param {object=} options - Configuration object.
58+
* @param {number} options.generation - Generation to scope the file to.
6059
*/
6160
/**
6261
* A File object is created from your Bucket object using

lib/storage/index.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,31 @@ Storage.prototype.bucket = function(name) {
190190
* @param {function} callback - The callback function.
191191
*
192192
* @example
193-
* storage.createBucket('new-bucket', function(err, bucket, apiResponse) {
193+
* var callback = function(err, bucket, apiResponse) {
194194
* // `bucket` is a Bucket object.
195-
* });
195+
* };
196+
*
197+
* storage.createBucket('new-bucket', callback);
196198
*
197-
* // Specifying metadata.
199+
* //-
200+
* // Specify metadata.
201+
* //-
198202
* var metadata = {
199203
* mainPageSuffix: '/unknown/',
200204
* maxAgeSeconds: 90
201205
* };
202206
*
203-
* var callback = function(err, bucket, apiResponse) {
204-
* // `bucket` is a Bucket object.
205-
* }
207+
* storage.createBucket('new-bucket', metadata, callback);
208+
*
209+
* //-
210+
* // Enable versioning on a new bucket.
211+
* //-
212+
* var metadata = {
213+
* versioning: {
214+
* enabled: true
215+
* }
216+
* };
217+
*
206218
* storage.createBucket('new-bucket', metadata, callback);
207219
*/
208220
Storage.prototype.createBucket = function(name, metadata, callback) {

0 commit comments

Comments
 (0)