Return file body with given Content-Type.


Traditionally, files that were returned by a web server with unprocessed bodies were called static files - hence the name.


Set the file’s content-type string attribute to the desired content-type. For example text/plain; charset=UTF-8, image/png.

Alternatively, if no content-type is provided, the system will automatically fill in the content-type for the file extensions below. For the rest, it will return application/octet-stream, which allows users to download the file.

Recognized file extensions

The list below may be appended at any time. We are not going to introduce breaking changes.

// Text
example.js -> "text/javascript; charset=UTF-8"
example.css -> "text/css; charset=UTF-8"
example.html -> "text/html; charset=UTF-8"
example.xml -> "application/xml; charset=UTF-8"
example.txt -> "text/plain; charset=UTF-8"

// Image formats
example.jpg -> "image/jpeg"
example.png -> "image/png"
example.gif -> "image/gif"
example.svg -> "image/svg+xml"
example.ico -> "image/x-icon"

// Fonts
example.eot -> "application/"
example.otf -> "application/font-sfnt"
example.ttf -> "application/font-sfnt"
example.woff -> "application/font-woff"
example.woff2 -> "application/font-woff2"

// Document formats
example.pdf -> "application/pdf"
example.doc -> "application/msword"
example.docx -> "application/msword"
example.xls -> "application/"
example.xlsx -> "application/"
example.ppt -> "application/"
example.pptx -> "application/"