FreeAsInBeer
FreeAsInBeer

Reputation: 12979

Check if a file is complete after downloading in Objective-c

I am implementing resumable file downloading for the iPhone, and I need to know how I can tell whether a file I have previously downloaded is complete or not before I attempt to redownload.

Upvotes: 1

Views: 890

Answers (2)

occulus
occulus

Reputation: 17014

You'll need to store the information about the size of the complete file somewhere that can be matched up with the partially downloaded file -- or, in the least, something that indicates the file is partially downloaded.

When your app wants to do anything with any of the downloaded files, it needs to check for partially downloaded content (i.e. actual size of data you have < complete file size) -- if it's only downloaded partially, it needs to kick off a resume download.

Without more specific info, can't say much more than that!

Upvotes: 0

FreeAsInBeer
FreeAsInBeer

Reputation: 12979

I've decided to use a '.part' or similar extension for files that are in progress of being downloaded. Then once the -(void)connectionDidFinishLoading:(NSURLConnection *)connection method executes, I will rename it.

Upvotes: 1

Related Questions