@@ -25,9 +25,7 @@ import {paginator} from '@google-cloud/paginator';
2525import { promisifyAll } from '@google-cloud/promisify' ;
2626import * as fs from 'fs' ;
2727import * as http from 'http' ;
28- import mime from 'mime' ;
2928import * as path from 'path' ;
30- import pLimit from 'p-limit' ;
3129import { promisify } from 'util' ;
3230import AsyncRetry from 'async-retry' ;
3331import { convertObjKeysToSnakeCase } from './util.js' ;
@@ -67,6 +65,8 @@ import {
6765} from './nodejs-common/service-object.js' ;
6866import { GaxiosError } from 'gaxios' ;
6967import { StorageQueryParameters } from './storage-transport.js' ;
68+ import mime from 'mime' ;
69+ import pLimit from 'p-limit' ;
7070
7171interface SourceObject {
7272 name : string ;
@@ -540,7 +540,7 @@ export enum BucketExceptionMessages {
540540 SPECIFY_FILE_NAME = 'A file name must be specified.' ,
541541 METAGENERATION_NOT_PROVIDED = 'A metageneration must be provided.' ,
542542 SUPPLY_NOTIFICATION_ID = 'You must supply a notification ID.' ,
543- INVAILD_CHANNEL_RESPONSE = 'Response data was null' ,
543+ INVALID_CHANNEL_RESPONSE = 'Response data was null' ,
544544}
545545
546546/**
@@ -1342,7 +1342,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
13421342 * **Note**: For configuring a raw-formatted rule object to be passed as `action`
13431343 * please refer to the [examples]{@link https://cloud.google.com/storage/docs/managing-lifecycles#configexamples}.
13441344 * @param {object } rule.condition Condition a bucket must meet before the
1345- * action occurson the bucket. Refer to followitn supported [conditions]{@link https://cloud.google.com/storage/docs/lifecycle#conditions}.
1345+ * action occurs on the bucket. Refer to following supported [conditions]{@link https://cloud.google.com/storage/docs/lifecycle#conditions}.
13461346 * @param {string } [rule.storageClass] When using the `setStorageClass`
13471347 * action, provide this option to dictate which storage class the object
13481348 * should update to.
@@ -1690,7 +1690,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
16901690 method : 'POST' ,
16911691 url : '/compose' ,
16921692 maxRetries,
1693- body : {
1693+ body : JSON . stringify ( {
16941694 destination : {
16951695 contentType : destinationFile . metadata . contentType ,
16961696 contentEncoding : destinationFile . metadata . contentEncoding ,
@@ -1708,7 +1708,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
17081708
17091709 return sourceObject ;
17101710 } ) ,
1711- } ,
1711+ } ) ,
17121712 queryParameters : options as unknown as StorageQueryParameters ,
17131713 } ,
17141714 ( err , resp ) => {
@@ -1851,13 +1851,15 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
18511851 . makeRequest < CreateChannel > (
18521852 {
18531853 method : 'POST' ,
1854- url : `${ this . baseUrl } /o/watch` ,
1855- body : Object . assign (
1856- {
1857- id,
1858- type : 'web_hook' ,
1859- } ,
1860- config ,
1854+ url : `${ this . baseUrl } /${ this . name } /o/watch` ,
1855+ body : JSON . stringify (
1856+ Object . assign (
1857+ {
1858+ id,
1859+ type : 'web_hook' ,
1860+ } ,
1861+ config ,
1862+ ) ,
18611863 ) ,
18621864 queryParameters : options as unknown as StorageQueryParameters ,
18631865 } ,
@@ -1876,7 +1878,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
18761878 return ;
18771879 }
18781880 callback ! (
1879- new Error ( BucketExceptionMessages . INVAILD_CHANNEL_RESPONSE ) ,
1881+ new Error ( BucketExceptionMessages . INVALID_CHANNEL_RESPONSE ) ,
18801882 null ,
18811883 resp ,
18821884 ) ;
@@ -1978,7 +1980,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
19781980 * myBucket.createNotification('my-topic', callback);
19791981 *
19801982 * //-
1981- * // Configure the nofiication by providing Notification metadata.
1983+ * // Configure the notification by providing Notification metadata.
19821984 * //-
19831985 * const metadata = {
19841986 * objectNamePrefix: 'prefix-'
@@ -2044,8 +2046,8 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
20442046 . makeRequest (
20452047 {
20462048 method : 'POST' ,
2047- url : `${ this . baseUrl } /notificationConfigs` ,
2048- body : convertObjKeysToSnakeCase ( body ) ,
2049+ url : `${ this . baseUrl } /${ this . name } / notificationConfigs` ,
2050+ body : JSON . stringify ( convertObjKeysToSnakeCase ( body ) ) ,
20492051 queryParameters : query as unknown as StorageQueryParameters ,
20502052 retry : false ,
20512053 } ,
@@ -2859,7 +2861,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
28592861 this . storageTransport
28602862 . makeRequest < GetFilesResponseData > (
28612863 {
2862- url : `${ this . baseUrl } /${ this . id } /o` ,
2864+ url : `${ this . baseUrl } /${ this . name } /o` ,
28632865 queryParameters : query as unknown as StorageQueryParameters ,
28642866 } ,
28652867 ( err , data , resp ) => {
@@ -3058,7 +3060,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
30583060 this . storageTransport
30593061 . makeRequest < GetNotificationsResponseData > (
30603062 {
3061- url : `${ this . baseUrl } /notificationConfigs` ,
3063+ url : `${ this . baseUrl } /${ this . name } / notificationConfigs` ,
30623064 queryParameters : options as unknown as StorageQueryParameters ,
30633065 } ,
30643066 ( err , data , resp ) => {
@@ -3104,7 +3106,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
31043106 * @property {boolean } [virtualHostedStyle=false] Use virtual hosted-style
31053107 * URLs ('https://mybucket.storage.googleapis.com/...') instead of path-style
31063108 * ('https://storage.googleapis.com/mybucket/...'). Virtual hosted-style URLs
3107- * should generally be preferred instaed of path-style URL.
3109+ * should generally be preferred instead of path-style URL.
31083110 * Currently defaults to `false` for path-style, although this may change in a
31093111 * future major-version release.
31103112 * @property {string } [cname] The cname for this bucket, i.e.,
@@ -3151,7 +3153,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
31513153 * @param {boolean } [config.virtualHostedStyle=false] Use virtual hosted-style
31523154 * URLs ('https://mybucket.storage.googleapis.com/...') instead of path-style
31533155 * ('https://storage.googleapis.com/mybucket/...'). Virtual hosted-style URLs
3154- * should generally be preferred instaed of path-style URL.
3156+ * should generally be preferred instead of path-style URL.
31553157 * Currently defaults to `false` for path-style, although this may change in a
31563158 * future major-version release.
31573159 * @param {string } [config.cname] The cname for this bucket, i.e.,
@@ -3255,7 +3257,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
32553257 * @throws {Error } if a metageneration is not provided.
32563258 *
32573259 * @param {number|string } metageneration The bucket's metageneration. This is
3258- * accesssible from calling {@link File#getMetadata}.
3260+ * accessible from calling {@link File#getMetadata}.
32593261 * @param {BucketLockCallback } [callback] Callback function.
32603262 * @returns {Promise<BucketLockResponse> }
32613263 *
@@ -3289,7 +3291,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
32893291 . makeRequest (
32903292 {
32913293 method : 'POST' ,
3292- url : `${ this . baseUrl } /lockRetentionPolicy` ,
3294+ url : `${ this . baseUrl } /${ this . name } / lockRetentionPolicy` ,
32933295 queryParameters : {
32943296 ifMetagenerationMatch : metageneration ,
32953297 } ,
@@ -3313,7 +3315,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
33133315 async restore ( options : RestoreOptions ) : Promise < Bucket > {
33143316 const bucket = await this . storageTransport . makeRequest < Bucket > ( {
33153317 method : 'POST' ,
3316- url : `${ this . baseUrl } /restore` ,
3318+ url : `${ this . baseUrl } /${ this . name } / restore` ,
33173319 queryParameters : options as unknown as StorageQueryParameters ,
33183320 } ) ;
33193321
0 commit comments