Re: File size of a downloadable file
Re: File size of a downloadable file
- Subject: Re: File size of a downloadable file
- From: Scott Anguish <email@hidden>
- Date: Sat, 17 Apr 2004 16:36:27 -0400
On Apr 17, 2004, at 2:02 PM, Pat Homelvig wrote:
*This message was transferred with a trial version of CommuniGate(tm)
Pro*
Does anyone know how you might be able to programmatically get the
size of a file you are going to download before you start downloading?
I would like to show the progress of downloading a file in my app
(xxxx bytes of yyyy bytes total).
The NSURLResponse returned by the connection:didReceiveResponse: (or
download:) delegate method includes a method -expectedContentLength.
it'll return the length that you can expect (if it's possible to
determine) or -1 if you can't.
then in your
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData
*)data
{
// append the new data to the receivedData
[receivedData append
Data:data];
}
you can increment the current length received data by checking the
length of the newly received data chunk and incrementing a counter..
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.