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

Function setObjectContexts

storage/setObjectContexts.js:44–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42 const storage = new Storage();
43
44 async function setObjectContexts() {
45 const file = storage.bucket(bucketName).file(fileName);
46
47 // Create/Update Object Contexts
48 // Object Contexts live in the 'contexts' field, not the 'metadata' field.
49 const [metadata] = await file.setMetadata({
50 contexts: {
51 custom: {
52 'team-owner': {value: 'storage-team'},
53 priority: {value: 'high'},
54 },
55 },
56 });
57
58 console.log(`Updated Object Contexts for ${fileName}:`);
59 console.log(JSON.stringify(metadata.contexts, null, 2));
60 }
61
62 setObjectContexts().catch(console.error);
63 // [END storage_set_object_contexts]

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected