I want continue download After I press 'startDownload' button, (Use resumeData)
when I second time enter app after app terminated.
Here is my Example code:
https://github.com/wgywgy/AlamofireDownloadDemo/tree/master
where to find resumeData?
You should save the "cancelledData" in a file and in second time enter app after app terminated you can read the data from that file as NSData.
Related
When I download a file and I'm inside the app everything works as it should, but when the user gets a call the download just stops
I read a bit and saw that it might be possible to use BGProcessingTaskRequest
But I don't know how to use it with Alamofire
I am implementing HLS downloader using AVAssetDownloadTask. I can't find a way to resume download if I restart the application in middle of download. The download always starts from beginning on app restart. I cannot find any mention of resuming downloads in the documentation of AVAssetDownloadTask. Let me know if anyone has successfully been able to resume download using AVAssetDownloadTask.
Thanks
Found this PDF titled "Offline Playback with FairPlay Streaming and HTTP Live Streaming" explaining how to resume downloads.
Found the following in a paragraph titled: "Resume Download"
AVAssetDownloadTask provides the ability to resume previously stopped
downloads under certain circumstances. To do so, simply instantiate a
new AVAssetDownloadTask with an AVURLAsset instantiated with a file
NSURL pointing to the partially downloaded bundle with the desired
download options, and the download will continue restoring any
previously downloaded data.
So you would need to cancel the download, then save the local NSURL of the partial download passed to the didFinishDownloadingTo delegate. The cancelled download can the be resumed by passing it the local NSURL of the partially downloaded file.
I am trying to download 4 video files, each one is approximately 50MB, using AfNetworking. I added this block to handle background download operation:
[weakSelf.downloadOperation setShouldExecuteAsBackgroundTaskWithExpirationHandler:^{
// Handle iOS shutting you down (possibly make a note of where you
// stopped so you can resume later)
}];
When it is downloading, if a call comes, or the phone goes standby mode, file seems to be downloaded, but actually it is not fully downloaded. So the app cannot open the downloaded video file. What should I do for that?
I've got a problem while downloading images in my iOS app. My app has the ability to download images form my server, but when I close the app while the download is being done and then I reopen it, for the app the image was fully downloaded, but when I open it it's crashed (half of the image looks OK, but the other half is all grey) and I can't find the way to handle this case.
Is there a way to handle this case? I mean, is there a way to know if the image is crashed, or any other thing that let's me know that the image wasn't downloaded ok for me to redownload it?
Wrap the image download code in calls to UIApplication beginBackgroundTaskWithExpirationHandler: and UIApplication endBackgroundTask:. In the expiration handler, stop the download and delete the partial file.
This allows the download to keep going for a few minutes in the background giving it more of a chance to complete. If it doesn't complete you delete the partial file preventing the issue of having a bad image. Of course you need to try to download again when your app returns to the foreground.
I would suggest you download an image first to a temporary location and when operation is finished successfully you move the image to it's permanent location (and make changes to database).
First make sure image is fully downloaded and then save it on device. Do not stream directly on disk.
Thanks in advance.
How can I stop downloading when some events occurred in wp7.For example when I am clicking a button named btnStop, all downloads should be terminated.
If a download is still in progess and you wish to cancel it simply call CancelAsync