I need to get the file size before downloading. And using a progressbar
here is my code works well unless if the file is hosted on Hostmonster server I would like to know what is the error.
The error is as follows: [NSConcreteMutableData initWithCapacity:]: absurd capacity: 4294967295, maximum size: 2147483648 bytes'
Here is my code
NSURL *url33;
NSNumber *filesize;
NSMutableData *data2;
url33 = [NSURL URLWithString: @ "http://www.nordenmovil.com/enconstruccion.jpg"];
- (void)connection: (NSURLConnection*) connection didReceiveResponse: (NSHTTPURLResponse*) response
{
filesize = [NSNumber numberWithUnsignedInteger:[response expectedContentLength]];
NSLog(@"%@",filesize);
}
- (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)recievedData {
[data2 appendData:recievedData];
if (data2==nil) {
data2 = [[NSMutableData alloc] initWithCapacity:[filesize floatValue]];
}
NSNumber *resourceLength = [NSNumber numberWithUnsignedInteger:[data2 length]]; //MAGIC
float progress = [resourceLength floatValue] / [filesize floatValue];
progressBar.progress = progress;
}