firebase-storage-kit

Content type

Set the MIME type on uploaded files for previews and downloads.

Content type (MIME type) tells browsers and clients how to handle a file — display an image inline, play audio, or download as a document. Without it, Firebase often stores files as application/octet-stream, which breaks previews and can force downloads instead of rendering.

Set contentType in UploadOptions at upload time. Read it back later with getMetadata.

Set content type on upload

const handle = manager.uploadFile(file, {
  path: `uploads/${file.name}`,
  contentType: file.type || "application/octet-stream",
});

The browser File object usually provides a MIME type via file.type. Some files (especially on certain platforms) may have an empty file.type — use a fallback when needed.

Read content type later

const meta = await manager.getMetadata(`uploads/${file.name}`);
console.log(meta.contentType); // e.g. "image/jpeg"

Batch uploads

Pass contentType in the per-file options:

manager.uploadFiles(files, (file) => ({
  path: `uploads/${file.name}`,
  contentType: file.type || "application/octet-stream",
}));

Content type vs custom metadata

contentType is the object's MIME type (e.g. image/png, application/pdf). customMetadata is for app-specific string tags (owner ID, source app, etc.). They are separate fields — use both when you need correct file handling and custom tags.

On this page