In my app, i want to download video files from server and store that file in IPhone document directory.
For downloading i am using ASIHTTPRequest library and i have downloaded the video(in KB size) and stored into Document directory.
but, when i downloading the video(in MB size) means, the request takes more time for that video downloading and there is no result( I have been waiting above 15 mins but there is no download).
I have tried the below code in my app and this is single download from the server.
- (IBAction)grabURLInBackground:(id)sender
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSURL *url = [NSURL URLWithString:@"http://mobile.aghaven.com/Downloads/video/Movie.m4v"];
//NSString *file = [NSString stringWithFormat:@"%@/movie.mov", documentsDirectory];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
NSString* file = [documentsDirectory stringByAppendingPathComponent:@"Movie.m4v"];
[request setDelegate:self];
[request setTimeOutSeconds:60];
[request setNumberOfTimesToRetryOnTimeout:2];
[request setDownloadDestinationPath:file];
[request startAsynchronous];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
[[[[UIAlertView alloc] initWithTitle:@"Message"
message:@"Success!!!"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease] show];
}
this file(Movie.m4v) having 2.2 MB size and when i downloading this video from server means, there is no video downloaded.
Kindly suggest me how to download video files (in MB size) from server using ASIHTTPRequest?.
I am using XCode 4.2 with iOS 5 sdk.
If any sample code means its very helpful to me.
Thanks!!!