static-1

Return file body with given Content-Type.

Description

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

Usage

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/vnd.ms-fontobject"
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/vnd.ms-excel"
example.xlsx -> "application/vnd.ms-excel"
example.ppt -> "application/vnd.ms-powerpoint"
example.pptx -> "application/vnd.ms-powerpoint"