Developer Toolbox

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-stream

At 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/pdf for a PDF and image/png for 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: nosniff with files users uploaded, so a browser never runs one as HTML or script.

  • Use --data-binary

    curl -d @file strips line breaks, which corrupts binary files. --data-binary @file sends the bytes as they are, and -T file uploads them with PUT.