ios-Server file Breakpoint download

Source: Internet
Author: User

File Download basic steps:
1. Get the download link to create a response send request. (Use asynchronous requests to avoid blocking the main thread because the file is too large to download for a long time).
2. Create a file in the download directory when the response is received. create files using Nsfilehandle for internal file processing. (Verify that the file exists-write to the file using the Filehandleforwritingatpath method that Nsfilemanager creates the file--nsfilehandle).
3. When the data is received, the data received by the segment is written to the file
4. When the file is received, close the Nsfilehandle.
The above is the normal download step, here without code demonstration, the following to implement the breakpoint download function as an example.

Because the sandbox path is used frequently in this program, a get sandbox path method is provided first

Download Event

Pause Event

#pragma Mark---nsurlconnectiondatasource---

This completes the download and the breakpoint continues the download process!!!

ios-Server file Breakpoint download

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.