diff --git a/README.md b/README.md index 220e8f49e78..80778778254 100644 --- a/README.md +++ b/README.md @@ -174,16 +174,16 @@ var gcloud = require('gcloud'); // Authorizing on a per-API-basis. You don't need to do this if you auth on a // global basis (see Authorization section above). -var storage = gcloud.storage({ +var gcs = gcloud.storage({ keyFilename: '/path/to/keyfile.json', projectId: 'my-project' }); // Create a new bucket. -storage.createBucket('my-new-bucket', function(err, bucket) {}); +gcs.createBucket('my-new-bucket', function(err, bucket) {}); // Reference an existing bucket. -var bucket = storage.bucket('my-bucket'); +var bucket = gcs.bucket('my-bucket'); // Upload a local file to a new file to be created in your bucket. var fileStream = fs.createReadStream('/local/file.txt'); diff --git a/docs/site/home.html b/docs/site/home.html index 6cb076b504c..75628d6c7dd 100755 --- a/docs/site/home.html +++ b/docs/site/home.html @@ -102,9 +102,9 @@

Example: Upload a file to Cloud Storage

projectId: 'grape-spaceship-123' }); -var storage = gcloud.storage(); +var gcs = gcloud.storage(); -var backups = storage.bucket('backups'); +var backups = gcs.bucket('backups'); backups.upload('db.zip', function(err, file) { // file.createReadStream(); // file.getMetadata(); @@ -118,9 +118,9 @@

Example: Upload a file to Cloud Storage

keyFilename: '/path/to/keyfile.json' }); -var storage = gcloud.storage(); +var gcs = gcloud.storage(); -var backups = storage.bucket('backups'); +var backups = gcs.bucket('backups'); backups.upload('db.zip', function(err, file) { // file.createReadStream(); // file.getMetadata(); diff --git a/lib/bigquery/table.js b/lib/bigquery/table.js index 95644a97d5e..6b031af55ff 100644 --- a/lib/bigquery/table.js +++ b/lib/bigquery/table.js @@ -369,10 +369,10 @@ Table.prototype.delete = function(callback) { * @throws {Error} If destination format isn't recongized. * * @example - * var storage = gcloud.storage({ + * var gcs = gcloud.storage({ * projectId: 'grape-spaceship-123' * }); - * var exportedFile = storage.bucket('institutions').file('2014.csv'); + * var exportedFile = gcs.bucket('institutions').file('2014.csv'); * * //- * // To use the default options, just pass a {module:storage/file} object. @@ -397,8 +397,8 @@ Table.prototype.delete = function(callback) { * // You can also specify multiple destination files. * //- * table.export([ - * storage.bucket('institutions').file('2014.json'), - * storage.bucket('institutions-copy').file('2014.json') + * gcs.bucket('institutions').file('2014.json'), + * gcs.bucket('institutions-copy').file('2014.json') * ], options, function(err, job, apiResponse) {}); */ Table.prototype.export = function(destination, options, callback) { @@ -606,17 +606,17 @@ Table.prototype.getRows = function(options, callback) { * table.import('./my-data.csv', metadata, function(err, job, apiResponse) {}); * * //- - * // Load data from a file in your Storage bucket. + * // Load data from a file in your Cloud Storage bucket. * //- - * var data = storage.bucket('institutions').file('data.csv'); + * var data = gcs.bucket('institutions').file('data.csv'); * table.import(data, function(err, job, apiResponse) {}); * * //- - * // Load data from multiple files in your Storage bucket(s). + * // Load data from multiple files in your Cloud Storage bucket(s). * //- * table.import([ - * storage.bucket('institutions').file('2011.csv'), - * storage.bucket('institutions').file('2012.csv') + * gcs.bucket('institutions').file('2011.csv'), + * gcs.bucket('institutions').file('2012.csv') * ], function(err, job, apiResponse) {}); */ Table.prototype.import = function(source, metadata, callback) { diff --git a/lib/index.js b/lib/index.js index ac242add2a9..38a751d90a7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -95,8 +95,8 @@ var util = require('./common/util.js'); * // projectId: 'my-project' * // }); * - * var storage = gcloud.storage(); - * var bucket = storage.bucket({ + * var gcs = gcloud.storage(); + * var bucket = gcs.bucket({ * name: 'PhotosBucket', * // properties may be overridden: * keyFilename: '/path/to/other/keyfile.json' @@ -205,7 +205,7 @@ gcloud.pubsub = function(config) { * * @example * var gcloud = require('gcloud'); - * var storage = gcloud.storage({ + * var gcs = gcloud.storage({ * projectId: 'project-id', * keyFilename: '/path/to/keyfile.json' * }); diff --git a/lib/storage/acl.js b/lib/storage/acl.js index 84d5fecea38..60a90209f5c 100644 --- a/lib/storage/acl.js +++ b/lib/storage/acl.js @@ -99,14 +99,14 @@ function Acl(options) { * @return {object} * * @example - * var storage = gcloud.storage({ + * var gcs = gcloud.storage({ * projectId: 'grape-spaceship-123' * }); * * //- * // Add a user as an owner of a file. * //- - * var myBucket = storage.bucket('my-bucket'); + * var myBucket = gcs.bucket('my-bucket'); * var myFile = myBucket.file('my-file'); * myFile.acl.owners.addUser('email@example.com', function(err, aclObject) {}); * @@ -115,7 +115,7 @@ function Acl(options) { * //- * myFile.acl.add({ * entity: 'user-email@example.com', - * role: storage.acl.OWNER_ROLE + * role: gcs.acl.OWNER_ROLE * }, function(err, aclObject) {}); */ Acl.prototype.owners = {}; @@ -154,7 +154,7 @@ Acl.prototype.owners = {}; * //- * myFile.acl.add({ * entity: 'user-email@example.com', - * role: storage.acl.READER_ROLE + * role: gcs.acl.READER_ROLE * }, function(err, aclObject) {}); */ Acl.prototype.readers = {}; @@ -193,7 +193,7 @@ Acl.prototype.readers = {}; * //- * myFile.acl.add({ * entity: 'user-email@example.com', - * role: storage.acl.WRITER_ROLE + * role: gcs.acl.WRITER_ROLE * }, function(err, aclObject) {}); */ Acl.prototype.writers = {}; @@ -216,7 +216,7 @@ nodeutil.inherits(Acl, AclRoleAccessorMethods); * @example * myBucket.acl.add({ * entity: 'user-useremail@example.com', - * role: storage.acl.OWNER_ROLE + * role: gcs.acl.OWNER_ROLE * }, function(err, aclObject, apiResponse) {}); * * //- @@ -226,7 +226,7 @@ nodeutil.inherits(Acl, AclRoleAccessorMethods); * //- * myFile.acl.add({ * entity: 'user-useremail@example.com', - * role: storage.acl.OWNER_ROLE, + * role: gcs.acl.OWNER_ROLE, * generation: 1 * }, function(err, aclObject, apiResponse) {}); */ @@ -383,13 +383,13 @@ Acl.prototype.get = function(options, callback) { * @alias acl.update * * @example - * var storage = gcloud.storage({ + * var gcs = gcloud.storage({ * projectId: 'grape-spaceship-123' * }); * * myBucket.acl.update({ * entity: 'user-useremail@example.com', - * role: storage.acl.WRITER_ROLE + * role: gcs.acl.WRITER_ROLE * }, function(err, apiResponse) {}); * * //- @@ -397,7 +397,7 @@ Acl.prototype.get = function(options, callback) { * //- * myFile.acl.update({ * entity: 'user-useremail@example.com', - * role: storage.acl.WRITER_ROLE, + * role: gcs.acl.WRITER_ROLE, * generation: 1 * }, function(err, apiResponse) {}); */ diff --git a/lib/storage/bucket.js b/lib/storage/bucket.js index 435d98c7f08..742647c0ce0 100644 --- a/lib/storage/bucket.js +++ b/lib/storage/bucket.js @@ -78,11 +78,11 @@ var RESUMABLE_THRESHOLD = 5000000; * @example * var gcloud = require('gcloud'); * - * var storage = gcloud.storage({ + * var gcs = gcloud.storage({ * projectId: 'grape-spaceship-123' * }); * - * var albums = storage.bucket('albums'); + * var albums = gcs.bucket('albums'); */ function Bucket(storage, name) { this.metadata = {}; @@ -122,10 +122,10 @@ function Bucket(storage, name) { * //- * // Make a bucket's contents publicly readable. * //- - * var myBucket = storage.bucket('my-bucket'); + * var myBucket = gcs.bucket('my-bucket'); * myBucket.acl.add({ * scope: 'allUsers', - * role: storage.acl.READER_ROLE + * role: gcs.acl.READER_ROLE * }, function(err, aclObject) {}); */ this.acl = new Acl({ @@ -215,7 +215,7 @@ function Bucket(storage, name) { * @param {function=} callback - The callback function. * * @example - * var logBucket = storage.bucket('log-bucket'); + * var logBucket = gcs.bucket('log-bucket'); * * var logs2013 = logBucket.file('2013-logs.txt'); * var logs2014 = logBucket.file('2014-logs.txt'); @@ -302,7 +302,7 @@ Bucket.prototype.combine = function(sources, destination, callback) { * @param {function=} callback - The callback function. * * @example - * var bucket = storage.bucket('delete-me'); + * var bucket = gcs.bucket('delete-me'); * bucket.delete(function(err, apiResponse) {}); */ Bucket.prototype.delete = function(callback) { diff --git a/lib/storage/file.js b/lib/storage/file.js index 06b1b564020..d5f20e7531f 100644 --- a/lib/storage/file.js +++ b/lib/storage/file.js @@ -107,15 +107,15 @@ function File(bucket, name, options) { * //- * // Make a file publicly readable. * //- - * var storage = gcloud.storage({ + * var gcs = gcloud.storage({ * projectId: 'grape-spaceship-123' * }); * - * var myFile = storage.bucket('my-bucket').file('my-file'); + * var myFile = gcs.bucket('my-bucket').file('my-file'); * * myFile.acl.add({ * scope: 'allUsers', - * role: storage.acl.READER_ROLE + * role: gcs.acl.READER_ROLE * }, function(err, aclObject) {}); */ this.acl = new Acl({ @@ -142,7 +142,7 @@ function File(bucket, name, options) { * // For all of the below examples, assume we are working with the following * // Bucket and File objects. * //- - * var bucket = storage.bucket('my-bucket'); + * var bucket = gcs.bucket('my-bucket'); * var file = bucket.file('my-image.png'); * * //- @@ -162,7 +162,7 @@ function File(bucket, name, options) { * // If you pass in a Bucket object, the file will be copied to that bucket * // using the same name. * //- - * var anotherBucket = storage.bucket('another-bucket'); + * var anotherBucket = gcs.bucket('another-bucket'); * file.copy(anotherBucket, function(err, copiedFile, apiResponse) { * // `my-bucket` still contains: * // - "my-image.png" @@ -266,7 +266,7 @@ File.prototype.copy = function(destination, callback) { * // For all of the below examples, assume we are working with the following * // Bucket and File objects. * //- - * var bucket = storage.bucket('my-bucket'); + * var bucket = gcs.bucket('my-bucket'); * var file = bucket.file('my-image.png'); * * //- @@ -287,7 +287,7 @@ File.prototype.copy = function(destination, callback) { * // If you pass in a Bucket object, the file will be moved to that bucket * // using the same name. * //- - * var anotherBucket = storage.bucket('another-bucket'); + * var anotherBucket = gcs.bucket('another-bucket'); * * file.move(anotherBucket, function(err, destinationFile, apiResponse) { * // `my-bucket` no longer contains: @@ -373,7 +373,7 @@ File.prototype.move = function(destination, callback) { * // backup of your remote data. * //- * var fs = require('fs'); - * var myBucket = storage.bucket('my-bucket'); + * var myBucket = gcs.bucket('my-bucket'); * var image = myBucket.file('image.png'); * * image.createReadStream() diff --git a/lib/storage/index.js b/lib/storage/index.js index 05d32dc798d..e41a9ee8654 100644 --- a/lib/storage/index.js +++ b/lib/storage/index.js @@ -74,7 +74,7 @@ var STORAGE_BASE_URL = 'https://www.googleapis.com/storage/v1/b'; * projectId: 'my-project' * }); * - * var storage = gcloud.storage(); + * var gcs = gcloud.storage(); */ function Storage(options) { if (!(this instanceof Storage)) { @@ -105,9 +105,9 @@ function Storage(options) { * This object provides constants to refer to the three permission levels that * can be granted to a scope: * - * - `storage.acl.OWNER_ROLE` - ("OWNER") - * - `storage.acl.READER_ROLE` - ("READER") - * - `storage.acl.WRITER_ROLE` - ("WRITER") + * - `gcs.acl.OWNER_ROLE` - ("OWNER") + * - `gcs.acl.READER_ROLE` - ("READER") + * - `gcs.acl.WRITER_ROLE` - ("WRITER") * * For more detailed information, see * [About Access Control Lists](http://goo.gl/6qBBPO). @@ -115,18 +115,18 @@ function Storage(options) { * @type {object} * * @example - * var storage = gcloud.storage({ + * var gcs = gcloud.storage({ * projectId: 'grape-spaceship-123' * }); * - * var albums = storage.bucket('albums'); + * var albums = gcs.bucket('albums'); * * //- * // Make all of the files currently in a bucket publicly readable. * //- * albums.acl.add({ * scope: 'allUsers', - * role: storage.acl.READER_ROLE + * role: gcs.acl.READER_ROLE * }, function(err, aclObject) {}); * * //- @@ -134,7 +134,7 @@ function Storage(options) { * //- * albums.acl.default.add({ * scope: 'allUsers', - * role: storage.acl.READER_ROLE + * role: gcs.acl.READER_ROLE * }, function(err, aclObject) {}); * * //- @@ -143,7 +143,7 @@ function Storage(options) { * * albums.acl.add({ * scope: 'user-useremail@example.com', - * role: storage.acl.OWNER_ROLE + * role: gcs.acl.OWNER_ROLE * }, function(err, aclObject) {}); */ Storage.acl = { @@ -166,10 +166,10 @@ Storage.prototype.acl = Storage.acl; * keyFilename: '/path/to/keyfile.json' * }); * - * var storage = gcloud.storage(); + * var gcs = gcloud.storage(); * - * var albums = storage.bucket('albums'); - * var photos = storage.bucket('photos'); + * var albums = gcs.bucket('albums'); + * var photos = gcs.bucket('photos'); */ Storage.prototype.bucket = function(name) { return new Bucket(this, name); @@ -189,7 +189,7 @@ Storage.prototype.bucket = function(name) { * // `bucket` is a Bucket object. * }; * - * storage.createBucket('new-bucket', callback); + * gcs.createBucket('new-bucket', callback); * * //- * // Specify metadata. @@ -199,7 +199,7 @@ Storage.prototype.bucket = function(name) { * maxAgeSeconds: 90 * }; * - * storage.createBucket('new-bucket', metadata, callback); + * gcs.createBucket('new-bucket', metadata, callback); * * //- * // Enable versioning on a new bucket. @@ -210,7 +210,7 @@ Storage.prototype.bucket = function(name) { * } * }; * - * storage.createBucket('new-bucket', metadata, callback); + * gcs.createBucket('new-bucket', metadata, callback); */ Storage.prototype.createBucket = function(name, metadata, callback) { var self = this; @@ -250,11 +250,11 @@ Storage.prototype.createBucket = function(name, metadata, callback) { * @param {function} callback - The callback function. * * @example - * storage.getBuckets(function(err, buckets, nextQuery) { + * gcs.getBuckets(function(err, buckets, nextQuery) { * if (nextQuery) { * // nextQuery will be non-null if there are more results. * var callback = function(err, buckets, nextQuery, apiResponse){}; - * storage.getBuckets(nextQuery, callback); + * gcs.getBuckets(nextQuery, callback); * } * * // The `metadata` property is populated for you with the metadata at the @@ -269,7 +269,7 @@ Storage.prototype.createBucket = function(name, metadata, callback) { * //- * // Fetch using a query. * //- - * storage.getBuckets({ + * gcs.getBuckets({ * maxResults: 5 * }, function(err, buckets, nextQuery, apiResponse) {}); */