File references and metadata

file path

A file is uniquely identified by its path in the bucket: it is unambiguous ID. The path includes the file extension.

file reference

We use references to interact with files. We build references by providing the file path:

const fileRef = ref(storage, "tts/2F14Izjv.mp3")
const fileRef = bucket.file("tts/2F14Izjv.mp3") // admin SDK

The file reference does not guarantee the file existence. The reference properties are of limited use (client SDK) and confusing:

ref.bucket // "abc.firebasestorage.app"
ref.fullPath // "tts/2F14Izjv.mp3"
ref.name // "2F14Izjv.mp3"

// computed references
ref.parent // ref(storage, "tts")
ref.root // ref(storage, "/")

bucket file's metadata

We fetch an existing file's metadata:

const metadata = await getMetadata(fileRef) // client SDK

It is a FullMetadata instance. We have:

  • the file size in bytes
  • the MIME type
  • the date of creation as an ISO string:
// repeat from fileRef
metadata.bucket
metadata.fullPath
metadata.name

// size, type and time
metadata.size // 1048576
metadata.contentType // "audio/mpeg"
metadata.timeCreated // "2026-01-04T12:34:56.789Z"

metadata.ref // file reference
earlymorning logo

© Antoine Weber 2026 - All rights reserved

File references and metadata

file path

A file is uniquely identified by its path in the bucket: it is unambiguous ID. The path includes the file extension.

file reference

We use references to interact with files. We build references by providing the file path:

const fileRef = ref(storage, "tts/2F14Izjv.mp3")
const fileRef = bucket.file("tts/2F14Izjv.mp3") // admin SDK

The file reference does not guarantee the file existence. The reference properties are of limited use (client SDK) and confusing:

ref.bucket // "abc.firebasestorage.app"
ref.fullPath // "tts/2F14Izjv.mp3"
ref.name // "2F14Izjv.mp3"

// computed references
ref.parent // ref(storage, "tts")
ref.root // ref(storage, "/")

bucket file's metadata

We fetch an existing file's metadata:

const metadata = await getMetadata(fileRef) // client SDK

It is a FullMetadata instance. We have:

  • the file size in bytes
  • the MIME type
  • the date of creation as an ISO string:
// repeat from fileRef
metadata.bucket
metadata.fullPath
metadata.name

// size, type and time
metadata.size // 1048576
metadata.contentType // "audio/mpeg"
metadata.timeCreated // "2026-01-04T12:34:56.789Z"

metadata.ref // file reference