Allowing all file types to be Downloaded from File Manager

By default, you can upload any type of file to Rock's file manager (Admin Tools - CMS Configuration - File Manager), and use those links on your website for people to download the file. This works great for .pdf, .jpg, or many other common file formats. This however, can give very different results if you try to host a file that is more obscure or not Windows native, like a .pages or a .zpl file.

Here I have uploaded a file named "test.pages". This is just a text document I made with the ".txt" extension changed to ".pages" instead to mimic the Apple Pages program's saved files. When it is a txt extension, clicking the download link in File Manager or going to the URL of the uploaded file works as expected and the browser offers to save the file. But if it is a pages extension, Rock throws a "We can't find that page" error.

mimetypes0.PNG

This happens because out of the box, Windows hosting has a preloaded list of acceptable MIME Types. MIME stands for "Multipurpose Internet Mail Extensions" which your web server uses to know what types of files you are hosting. If your file type isn't on this list, it thinks it is trying to serve a webpage instead and thus, "We can't find that page" is displayed! Fixing this is simple, but requires access to the hosting server's Internet Information Services (IIS) console.

Let's get started:

1) Log into your web server's Windows interface and click Start and type "IIS" and it should appear to click. If it doesn't, you can manually look under the W section of the programs, and in the "Windows Administrative Tools" folder, you should see it listed.

2) Once open, navigate down to your website. If you haven't changed anything, yours will likely be called Default. For this example, we will look at my dev site.

mimetypes1.PNG

3) On the right side you will see a bunch of icons. Double click on "MIME Types" in the list.

mimetypes2.PNG

4) If you do a quick search down that list, you should see that the file type you are trying to download is not in the list. For example, there is no .pages file type. So we need to add it. Click "Add" at the top right.

mimetypes3.PNG

5) Gather your info. This is the part that requires a little sleuthing. If you Google search ".pages file MIME Type" I found that the correct MIME Type is:

application/vnd.apple.pages


This will vary for every file extension you want to add. There are internet resources out there to help find these as well, such as:
The official IANA list:        https://www.iana.org/assignments/media-types/media-types.xhtml
Mozilla's compiled list:        https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

Other 3rd party sites:
https://www.trivantis.com/help/CourseMill/7.4/en/Troubleshooting/Content/Troubleshooting_mime.html
https://www.sitepoint.com/mime-types-complete-list/
https://www.hostmysite.com/support/dedicated/iis/mimetypes/
https://www.freeformatter.com/mime-types-list.html#mime-types-list

Here are some common MIME Types which weren't on some of the lists:

Apple Keynote:.keynoteapplication/vnd.apple.keynote
Apple Pages:.pagesapplication/vnd.apple.pages
Apple Numbers:.numbersapplication/vnd.apple.numbers
Apple Apps:.ipaapplication/octet-stream
Apple plist:.plisttext/xml
Apple iBooks:.ibooksapplication/x-ibooks+zip
Zebra ZPL:.zplapplication/epl2

Note: "application/octet-stream" type identifies files that are not associated with a specific application. Instead this transfers the file as straight up binary data. This allows the end user's software to determine the best application to use.

6) Once you have the right info, pop it into the Add dialog box and hit OK. THIS WILL RESTART ROCK, so know that your site will be offline for a few seconds as it restarts. In other words, don't do this in the middle of peak use or during check-in.

mimetypes4.PNG

7) Once your site is back up, you should be able to click the download link on the File Manager for your file and get the save dialog! No more 404 errors! Yay!

mimetypes5.PNG

Important tech note:

If your web server locks up someday, and you run the "iisreset" command on your server, it will remove all of your custom MIME Types. You can either keep note of those you've added so you know which to re-add should you need to run iisreset at some point, or you can add them permanently to the config file instead by opening:

\Windows\System32\inetsrv\config\applicationHost.config

and searching for "mimeMap" to find the section of the file where they are all located. You'll see things like:

<mimeMap fileExtension=".aaf" mimeType="application/octet-stream" />

Add a line with your info and save the file... such as:

<mimeMap fileExtension=".pages" mimeType="application/vnd.apple.pages" />

After you save this file, you may need to stop/start your website in IIS, or stop/start the "World Wide Web Publishing Service" in services, or reboot the server. I'm not sure which is required to pull the new MIME Type into your site's list. All 3 of those are disruptive to your site and will take it down briefly, so do this during off-hours and check the MIME Type list in IIS to see if your custom type is there. Once you do this though, they should survive an "iisreset" command.