Skip to content

Commit 67a76e7

Browse files
committed
Merge pull request #607 from ryanseys/set-metadata-mergy-docs
Update setMetadata docs to clarify merging. And whitespace issues
2 parents c228014 + 251e2fa commit 67a76e7

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

lib/storage/file.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ File.prototype.getSignedPolicy = function(options, callback) {
10251025
* @param {string=} options.responseDisposition - The
10261026
* response-content-disposition parameter (http://goo.gl/yMWxQV) of the
10271027
* signed url.
1028-
* @param {string=} options.responseType - The response-content-type parameter
1028+
* @param {string=} options.responseType - The response-content-type parameter
10291029
* of the signed url.
10301030
* @param {function=} callback - The callback function.
10311031
*
@@ -1071,20 +1071,20 @@ File.prototype.getSignedUrl = function(options, callback) {
10711071

10721072
var responseContentType = '';
10731073
if (util.is(options.responseType, 'string')) {
1074-
responseContentType =
1075-
'&response-content-type=' +
1074+
responseContentType =
1075+
'&response-content-type=' +
10761076
encodeURIComponent(options.responseType);
10771077
}
10781078

10791079
var responseContentDisposition = '';
10801080
if (util.is(options.promptSaveAs, 'string')) {
10811081
responseContentDisposition =
1082-
'&response-content-disposition=attachment; filename="' +
1082+
'&response-content-disposition=attachment; filename="' +
10831083
encodeURIComponent(options.promptSaveAs) + '"';
10841084
}
10851085
if (util.is(options.responseDisposition, 'string')) {
1086-
responseContentDisposition =
1087-
'&response-content-disposition=' +
1086+
responseContentDisposition =
1087+
'&response-content-disposition=' +
10881088
encodeURIComponent(options.responseDisposition);
10891089
}
10901090

@@ -1100,9 +1100,17 @@ File.prototype.getSignedUrl = function(options, callback) {
11001100
};
11011101

11021102
/**
1103-
* Set the file's metadata.
1103+
* Merge the given metadata with the current remote file's metadata. This will
1104+
* set metadata if it was previously unset or update previously set metadata. To
1105+
* unset previously set metadata, set its value to null.
1106+
*
1107+
* You can set custom key/value pairs in the metadata key of the given object,
1108+
* however the other properties outside of this object must adhere to the
1109+
* [official API documentation](https://goo.gl/BOnnCK).
11041110
*
1105-
* @param {object} metadata - The metadata you wish to set.
1111+
* See the examples below for more information.
1112+
*
1113+
* @param {object} metadata - The metadata you wish to update.
11061114
* @param {function=} callback - The callback function.
11071115
*
11081116
* @example
@@ -1113,6 +1121,17 @@ File.prototype.getSignedUrl = function(options, callback) {
11131121
* properties: 'go here'
11141122
* }
11151123
* }, function(err, metadata, apiResponse) {});
1124+
*
1125+
* // Assuming current metadata = { hello: 'world', unsetMe: 'will do' }
1126+
* file.setMetadata({
1127+
* metadata: {
1128+
* abc: '123', // will be set.
1129+
* unsetMe: null, // will be unset (deleted).
1130+
* hello: 'goodbye' // will be updated from 'hello' to 'goodbye'.
1131+
* }
1132+
* }, function(err, metadata, apiResponse) {
1133+
* // metadata should now be { abc: '123', hello: 'goodbye' }
1134+
* });
11161135
*/
11171136
File.prototype.setMetadata = function(metadata, callback) {
11181137
callback = callback || util.noop;

0 commit comments

Comments
 (0)