-
Notifications
You must be signed in to change notification settings - Fork 242
/
storage_update_metadata.js
27 lines (23 loc) · 857 Bytes
/
storage_update_metadata.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// This snippet file was generated by processing the source file:
// ./storage-next/file-metadata.js
//
// To update the snippets in this file, edit the source and then run
// 'npm run snippets'.
// [START storage_update_metadata_modular]
import { getStorage, ref, updateMetadata } from "firebase/storage";
// Create a reference to the file whose metadata we want to change
const storage = getStorage();
const forestRef = ref(storage, 'images/forest.jpg');
// Create file metadata to update
const newMetadata = {
cacheControl: 'public,max-age=300',
contentType: 'image/jpeg'
};
// Update metadata properties
updateMetadata(forestRef, newMetadata)
.then((metadata) => {
// Updated metadata for 'images/forest.jpg' is returned in the Promise
}).catch((error) => {
// Uh-oh, an error occurred!
});
// [END storage_update_metadata_modular]