While attempting to download a PDF/Word/RTF file from a website, I observed that the download button, upon inspection, wasn't a direct link. Upon clicking the button, the file started downloading, and an octet-stream(blob:https://hiring.websiteName.com/dc7344cc-1cde-452f-8f92-a89ec666f934) link appeared in the chrome://downloads/ section. Subsequent attempts to download the same file resulted in the generation of random links in chrome://downloads/.
I'm interested in understanding how the website converts the octet-stream link to PDF/Word/RTF files.
Deriving Mime-Types is literally Magic
Here at MDN is a nice read on Mime-Types where they also mention some means of deriving the mime-type from a stream.
One common way to identify the content of a file is using the so called "Magic Numbers" of "Magic Bytes". These are some of the first characters/bytes in the contents of the file.
Here on another Wikipedia page you can read more on "Magic Numbers" in files.
And on this Wikipedia page you find a list of these file signatures.