firebase-storage-kit

Custom metadata

Attach string key-value metadata to uploaded files.

Custom metadata lets you store small, file-specific tags on a Storage object — owner ID, source app, content type label, etc. Set it at upload time and read it back with getMetadata.

Set metadata on upload

const handle = manager.uploadFile(file, {
  path: `uploads/${file.name}`,
  customMetadata: {
    owner: "user-123",
    source: "mobile-app",
  },
});

Read metadata later

const meta = await manager.getMetadata(`uploads/${file.name}`);
console.log(meta.customMetadata?.owner); // "user-123"

Batch uploads

Pass customMetadata in the per-file options:

manager.uploadFiles(files, (file) => ({
  path: `uploads/${file.name}`,
  customMetadata: { uploadedBy: userId },
}));

Important rules

String values only. Keys and values must both be strings (Record<string, string>). Numbers and objects are not supported.

Reserved keys. Do not set Firebase internal keys such as firebaseStorageDownloadTokens. Firebase rejects them with a 400 error.

Small data only. Custom metadata is for lightweight tags. For rich or queryable data, use Firestore or Realtime Database.

Security rules. Who can read or write metadata is controlled by your Storage security rules. Lock down sensitive fields in production.

On this page