MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

storage/setClientEndpoint.js:25–51  ·  view source on GitHub ↗

* This application demonstrates set a custom endpoint with * the Google Cloud Storage API. * * For more information, see the README.md under /storage and the documentation * at https://cloud.google.com/storage/docs.

(apiEndpoint = 'https://storage.googleapis.com')

Source from the content-addressed store, hash-verified

23 */
24
25function main(apiEndpoint = 'https://storage.googleapis.com') {
26 // [START storage_set_client_endpoint]
27 /**
28 * TODO(developer): Uncomment the following lines before running the sample.
29 */
30 // The custom endpoint to which requests should be made
31 // const apiEndpoint = 'https://yourcustomendpoint.com';
32
33 // Imports the Google Cloud client library
34 const {Storage} = require('@google-cloud/storage');
35 try {
36 // Creates a client
37 const storage = new Storage({
38 apiEndpoint: apiEndpoint,
39 useAuthWithCustomEndpoint: true,
40 });
41
42 console.log(`Client initiated with endpoint: ${storage.apiEndpoint}.`);
43 } catch (error) {
44 console.error(
45 'Error executing set client endpoint:',
46 error.message || error
47 );
48 }
49
50 // [END storage_set_client_endpoint]
51}
52
53main(...process.argv.slice(2));

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected