application/octet-stream
application/octet-stream says "a sequence of bytes" and nothing more. It is the fallback when no more specific type is known (RFC 2046), and what servers send for a file extension they have no mapping for.
Open in cURL Builder A request with this type is filled in.
Header
Content-Type: application/octet-streamAt a glance
- Extensions
- .bin
- Kind
- Binary
- Parameters
- None
- In a browser
- Downloads the file rather than displaying or running it, which makes this type a safe default for files you serve but have not checked.
With curl
curl -X PUT https://api.example.com/files/backup.bin \ -H 'Content-Type: application/octet-stream' \ --data-binary @backup.bin
With fetch
await fetch('https://api.example.com/files/backup.bin', {
method: 'PUT',
headers: { 'Content-Type': 'application/octet-stream' },
body: file // a Blob, File, ArrayBuffer or stream
});Common mistakes
A specific type is better
Send
application/pdffor a PDF andimage/pngfor a PNG when you know it. Clients choose a viewer, a cache policy or a parser from the type.Sniffing
Some clients look at the bytes when the type is this vague. Send
X-Content-Type-Options: nosniffwith files users uploaded, so a browser never runs one as HTML or script.Use
--data-binarycurl
-d @filestrips line breaks, which corrupts binary files.--data-binary @filesends the bytes as they are, and-T fileuploads them with PUT.