Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-05-2009, 02:45 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
brian515 is on a distinguished road
Default Download Large Files

Hi all,

I am trying to download a relatively large file from within my app. However, whenever it doesn't work and when I look in the folder in the iPhone Simulator folder in my Library, all I see is a 4kB file, nothing close to the 10 or 15mB it should be. Here is the code I am using.
Code:
	NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:theURL]];
	NSData *theData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil];
 	NSArray *path = (NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES));
	NSString *theDirectory = [path objectAtIndex:0];
	NSString *theName = [NSString stringWithFormat:@"movie.mov"];
	theDirectory = [theDirectory stringByAppendingPathComponent:movieName];
	[theData writeToFile:theDirectory atomically:YES];
Any help would be appreciated. Thanks!
brian515 is offline   Reply With Quote
Old 05-05-2009, 08:37 PM   #2 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 253
zhyla is on a distinguished road
Default

I don't know anything about writing files but is atomically:YES the right option here? How could you possibly write a large file atomically?
zhyla is offline   Reply With Quote
Old 05-05-2009, 08:41 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
brian515 is on a distinguished road
Default

Quote:
Originally Posted by zhyla View Post
I don't know anything about writing files but is atomically:YES the right option here? How could you possibly write a large file atomically?
Yea, I don't know if you could do that. I tried writing it non-atomically, but with the same result.
brian515 is offline   Reply With Quote
Old 05-06-2009, 10:31 AM   #4 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: San Diego, CA
Posts: 406
jtara is on a distinguished road
Default

This simplistic approach isn't going to work for large files, because it reads the entire request into memory first.

Haven't done any iPhone network programming, so don't know what alternatives you have to read the data in chunks. But that is what you need to do - read it in chunks, rather than in one big gulp.
jtara is offline   Reply With Quote
Reply

Bookmarks

Tags
download, file, internet, large, movie

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 320
8 members and 312 guests
blueorb, givensur, guusleijsten, jbro, mer10, n00b, SLIC, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:04 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0