CGI large file download

Source: Internet
Author: User

The client is pure HTMLCodeClick the link to download the file from the server. This is what I do on the server:
HTTP 1/1 200 OK
Content-Length = 500
Content-Type = application/octet-stream
Content-Disposition: attachment; filename = "1.zip"
After the above HTTP header is connected to the file stream I read, the client browser will be able to see the download box.

The problem is that the above Code seems to be able to only process small files. When there are large files, you must download them multiple times at a breakpoint. What information should the server return to the client browser? The client only has HTML pages ..

answer

To implement resumable data transfer, the HTTP request sent to the server must contain the range header and specify the start and end locations of the part to be downloaded. For example:
Range: bytes = 1000-2000

The server returns the part of the specified part according to the range instruction.

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.