The APK file link in the static page is directly opened instead of downloaded.

Source: Internet
Author: User

This problem is often encountered. It is also common to handle the default link behavior of JPG, PDF, SVG, and other types of files.

Whether the file is opened or downloaded depends on the Content-Type and content-disposition in the HTTP header,
Although the default type of the HTTP protocol for unknown media is octet-stream, the MIME standard default type is text/plain.
Therefore, the specific behavior depends on the application server's implementation of the HTTP protocol.

I encountered the default IMPLEMENTATION OF THE nginx server.

When nginx does not set default_type, the APK file is treated as the text/plain type, which causes the APK file to be opened rather than downloaded as a text file.
To download the file, use the nginx configuration command default_type:
Default_type application/octet-stream;

Based on the HTTP protocol

Http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html

The octet-stream8 BIT data stream represents an unknown media type, which is tested to be downloaded in FF/IE8 by default.

Of course, you can also modify the default page behavior by modifying the header Through the application.

Reference link:

1. http://wiki.nginx.org/HttpCoreModule#types

2. http://mattryall.net/blog/2008/03/default-content-type

3. http://www.vbulletin.com/forum/forum/general/chit-chat/72776-http-headers-to-force-file-to-download-rather-than-auto-open

4. http://www.boutell.com/newfaq/creating/forcedownload.html

The third link above explains in detail the use of content-disposition, where attachment is download, inline is open in the browser

By iefreer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.