Search code examples
mobile-safarimime-typespassbook

How to designate a downloadable file's content type


This SO answer applies to me, but I don't know how to "change the content type to application/vnd.apple.pkpass"

Currently a direct link to my pkpass triggers a download and I don't know where to set the content type.

I have asked my hosting provider to verify that "application/vnd.apple.pkpass" is a supported MIME type

I have tried

What can I do to make the file recognized as the "application/vnd.apple.pkpass" when the link is clicked from iOS 6 or Mac OS 10.8?


Solution

  • You need to change the web server's configuration to do this. How you do this depends on which web server you're using. If you have a hosting company that manages your site's server for you, you likely need to ask them to do this or tell you where you can.

    Many hosting companies use Apache for the web server. If so, you can create a .htaccess file in your public HTML directory, and put this in it:

    AddType application/vnd.apple.pkpass .pkpass
    

    This will make any file that ends in ".pkpass" get downloaded with that content type.

    This assumes you're having the client download a static file. If you're dynamically generating this file, you don't need to mess with the server at all, and just need to send a header. This depends on which scripting language you're using, for example in PHP you'd do:

    header("Content-Type: application/vnd.apple.pkpass");