Navigation

File Metadata Attributes

Overview

You can define metadata attributes for each file that you host with MongoDB Realm. Metadata attributes map to standard HTTP headers and allow you to optionally configure how Realm serves your files as well as how clients that request resources should handle them. This page provides examples and describes the purpose of each available attribute.

Content-Type

The Content-Type file attribute indicates the media type of the file.

Note

If you do not specify a Content-Type attribute for a file, Realm will attempt to automatically add a Content-Type attribute to it based on the file extension.

For example, Realm would automatically add the attribute Content-Type: application/html to the file myPage.html.

Examples

Indicate that a File Contains HTML

Content-Type: application/html

Content-Disposition

The Content-Disposition file attribute indicates to client applications (such as your web browser) whether the file should be downloaded as an attachment or displayed inline as a web page.

Examples

Display the File Inline

Content-Disposition: inline

Download the File

Content-Disposition: attachment

Download the File with a Custom Filename

Content-Disposition: attachment; filename="myFile.txt"

Content-Encoding

The Content-Encoding file attribute indicates any encodings that were applied to the file. Client applications can use this header to determine how to properly decode the file.

Examples

Indicate No Encoding

Content-Encoding: identity

Indicate GZIP Encoding

Content-Encoding: gzip

Indicate Multiple Encodings in Application Order

Content-Encoding: gzip, identity

Content-Language

The Content-Language file attribute optionally specifies the language used by the file’s intended target audience. This attribute does not necessarily represent the language that file is actually written in.

Examples

Specify a Single Language

Content-Language: en-US

Specify Multiple Languages

Content-Language: en-US, en-CA, en-UK

Cache-Control

The Cache-Control file attribute instructs CDN servers on how they should handle cached copies of the file.

Examples

Refresh a Cached File Every Five Minutes

Cache-Control: max-age=300

Never Cache a File

Cache-Control: no-cache