• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: File size of a downloadable file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 appendData: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.


  • Follow-Ups:
    • Re: File size of a downloadable file
      • From: Jeremy Dronfield <email@hidden>
References: 
 >File size of a downloadable file (From: Pat Homelvig <email@hidden>)

  • Prev by Date: Re: Cocoa vs User: 0 - 1
  • Next by Date: Re: The bitmap image type from an NSBitmapImageRep?
  • Previous by thread: Re: File size of a downloadable file
  • Next by thread: Re: File size of a downloadable file
  • Index(es):
    • Date
    • Thread