@@ -278,13 +278,11 @@ export enum ActionToHTTPMethod {
278278}
279279
280280/**
281- * @const {string}
282281 * @private
283282 */
284283export const STORAGE_POST_POLICY_BASE_URL = 'https://storage.googleapis.com' ;
285284
286285/**
287- * @const {RegExp}
288286 * @private
289287 */
290288const GS_URL_REGEXP = / ^ g s : \/ \/ ( [ a - z 0 - 9 _ . - ] + ) \/ ( .+ ) $ / ;
@@ -500,6 +498,68 @@ class File extends ServiceObject<File> {
500498 * @name File#name
501499 * @type {string }
502500 */
501+ /**
502+ * @callback Crc32cGeneratorToStringCallback
503+ * A method returning the CRC32C as a base64-encoded string.
504+ *
505+ * @returns {string }
506+ *
507+ * @example
508+ * Hashing the string 'data' should return 'rth90Q=='
509+ *
510+ * ```js
511+ * const buffer = Buffer.from('data');
512+ * crc32c.update(buffer);
513+ * crc32c.toString(); // 'rth90Q=='
514+ * ```
515+ **/
516+ /**
517+ * @callback Crc32cGeneratorValidateCallback
518+ * A method validating a base64-encoded CRC32C string.
519+ *
520+ * @param {string } [value] base64-encoded CRC32C string to validate
521+ * @returns {boolean }
522+ *
523+ * @example
524+ * Should return `true` if the value matches, `false` otherwise
525+ *
526+ * ```js
527+ * const buffer = Buffer.from('data');
528+ * crc32c.update(buffer);
529+ * crc32c.validate('DkjKuA=='); // false
530+ * crc32c.validate('rth90Q=='); // true
531+ * ```
532+ **/
533+ /**
534+ * @callback Crc32cGeneratorUpdateCallback
535+ * A method for passing `Buffer`s for CRC32C generation.
536+ *
537+ * @param {Buffer } [data] data to update CRC32C value with
538+ * @returns {undefined }
539+ *
540+ * @example
541+ * Hashing buffers from 'some ' and 'text\n'
542+ *
543+ * ```js
544+ * const buffer1 = Buffer.from('some ');
545+ * crc32c.update(buffer1);
546+ *
547+ * const buffer2 = Buffer.from('text\n');
548+ * crc32c.update(buffer2);
549+ *
550+ * crc32c.toString(); // 'DkjKuA=='
551+ * ```
552+ **/
553+ /**
554+ * @typedef {object } CRC32CValidator
555+ * @property {Crc32cGeneratorToStringCallback }
556+ * @property {Crc32cGeneratorValidateCallback }
557+ * @property {Crc32cGeneratorUpdateCallback }
558+ */
559+ /**
560+ * @callback Crc32cGeneratorCallback
561+ * @returns {CRC32CValidator }
562+ */
503563 /**
504564 * @typedef {object } FileOptions Options passed to the File constructor.
505565 * @property {string } [encryptionKey] A custom encryption key.
@@ -509,6 +569,7 @@ class File extends ServiceObject<File> {
509569 * usable only by enabled projects.
510570 * @property {string } [userProject] The ID of the project which will be
511571 * billed for all requests made from File object.
572+ * @property {Crc32cGeneratorCallback } [callback] A function that generates a CRC32C Validator. Defaults to {@link CRC32C}
512573 */
513574 /**
514575 * Constructs a file object.
0 commit comments