@@ -85,8 +85,8 @@ var STORAGE_UPLOAD_BASE_URL = 'https://www.googleapis.com/upload/storage/v1/b';
8585 * attached to.
8686 * @param {string } name - The name of the remote file.
8787 * @param {object= } options - Configuration object.
88+ * @param {string } options.encryptionKey - A custom encryption key.
8889 * @param {number } options.generation - Generation to scope the file to.
89- * @param {string } options.key - A custom encryption key.
9090 */
9191/**
9292 * A File object is created from your Bucket object using
@@ -242,8 +242,8 @@ function File(bucket, name, options) {
242242 methods : methods
243243 } ) ;
244244
245- if ( options . key ) {
246- this . setKey ( options . key ) ;
245+ if ( options . encryptionKey ) {
246+ this . setEncryptionKey ( options . encryptionKey ) ;
247247 }
248248
249249 /**
@@ -997,47 +997,48 @@ File.prototype.download = function(options, callback) {
997997
998998/**
999999 * The Storage API allows you to use a custom key for server-side encryption.
1000- * Supply this method with a passphrase and the correct key (AES-256) will be
1001- * generated and used for you.
10021000 *
10031001 * @resource [Customer-supplied Encryption Keys]{@link https://cloud.google.com/storage/docs/encryption#customer-supplied}
10041002 *
1005- * @param {string|buffer } key - An AES-256 encryption key.
1003+ * @param {string|buffer } encryptionKey - An AES-256 encryption key.
10061004 * @return {module:storage/file }
10071005 *
10081006 * @example
10091007 * var crypto = require('crypto');
10101008 * var encryptionKey = crypto.randomBytes(32);
10111009 *
10121010 * var fileWithCustomEncryption = myBucket.file('my-file');
1013- * fileWithCustomEncryption.setKey (encryptionKey);
1011+ * fileWithCustomEncryption.setEncryptionKey (encryptionKey);
10141012 *
10151013 * var fileWithoutCustomEncryption = myBucket.file('my-file');
10161014 *
10171015 * fileWithCustomEncryption.save('data', function(err) {
1018- * // Try to download with the File object that hasn't had `setKey()` called:
1016+ * // Try to download with the File object that hasn't had
1017+ * // `setEncryptionKey()` called:
10191018 * fileWithoutCustomEncryption.download(function(err) {
10201019 * // We will receive an error:
10211020 * // err.message === 'Bad Request'
10221021 *
1023- * // Try again with the File object we called `setKey ()` on:
1022+ * // Try again with the File object we called `setEncryptionKey ()` on:
10241023 * fileWithCustomEncryption.download(function(err, contents) {
10251024 * // contents.toString() === 'data'
10261025 * });
10271026 * });
10281027 * });
10291028 */
1030- File . prototype . setKey = function ( key ) {
1031- this . key = key ;
1029+ File . prototype . setEncryptionKey = function ( encryptionKey ) {
1030+ this . encryptionKey = encryptionKey ;
10321031
1033- key = new Buffer ( key ) . toString ( 'base64' ) ;
1034- var hash = crypto . createHash ( 'sha256' ) . update ( key , 'base64' ) . digest ( 'base64' ) ;
1032+ encryptionKey = new Buffer ( encryptionKey ) . toString ( 'base64' ) ;
1033+ var hash = crypto . createHash ( 'sha256' )
1034+ . update ( encryptionKey , 'base64' )
1035+ . digest ( 'base64' ) ;
10351036
10361037 this . interceptors . push ( {
10371038 request : function ( reqOpts ) {
10381039 reqOpts . headers = reqOpts . headers || { } ;
10391040 reqOpts . headers [ 'x-goog-encryption-algorithm' ] = 'AES256' ;
1040- reqOpts . headers [ 'x-goog-encryption-key' ] = key ;
1041+ reqOpts . headers [ 'x-goog-encryption-key' ] = encryptionKey ;
10411042 reqOpts . headers [ 'x-goog-encryption-key-sha256' ] = hash ;
10421043 return reqOpts ;
10431044 }
@@ -1613,7 +1614,7 @@ File.prototype.startResumableUpload_ = function(dup, options) {
16131614 bucket : this . bucket . name ,
16141615 file : this . name ,
16151616 generation : this . generation ,
1616- key : this . key ,
1617+ key : this . encryptionKey ,
16171618 metadata : options . metadata ,
16181619 offset : options . offset ,
16191620 predefinedAcl : options . predefinedAcl ,
0 commit comments