title: finding out the downloaded image file size in IOS
body: <p>Hello I would like to run a thread and check the current downloaded size of a file.</p>
  
  <p>This is what I use</p>
  
  <pre><code>UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://lasp.colorado.edu/home/wp-content/uploads/2011/03/suncombo1.jpg"]]];
  
  NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
  
  NSString *jpegFilePath = [NSString stringWithFormat:@"%@/test.jpeg",docDir];
  NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];//1.0f = 100% quality
  [data2 writeToFile:jpegFilePath atomically:YES];
  downloadStatus.text =[NSString stringWithFormat:@"size: %zd", malloc_size(data2)];
  
  [image release];
  </code></pre>
  
  <p>I have also tried to change malloc_size(data2) into image but again it is not the real result. I know this does not have thread and do not check during the download process but what am I supposed to use here to see the file size?</p>