PDA

View Full Version : cn't download mp3 file




erritikamathur
Nov 25, 2009, 05:54 AM
i m trying to download mp3 file from server but i m not getting any data

i m getting error as
Error {
NSLocalizedDescription = "bad URL";
NSUnderlyingError = Error Domain=kCFErrorDomainCFNetwork Code=-1000 UserInfo=0x1183ac0 "bad URL";
}
here is my code----
sender=@"http://sound13.mp3pk.com/indian/7days/7days01(www.songs.pk).mp3";
NSMutableURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:sender]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLResponse *res=NULL;
NSError *error=NULL;
NSData *data=[NSURLConnection sendSynchronousRequest:theRequest returningResponse:&res error:&error];
NSLog(@"download data---%@",[res URL]);

i need to store the data received from server.i cn't figure where i m missing&if i provided any path with .wma file or anything else it gets downloaded



robbieduncan
Nov 25, 2009, 07:00 AM
You cannot use quite a few characters in a URL. See here (http://www.blooberry.com/indexdot/html/topics/urlencoding.htm).

You need to encode your URL. There is an obvious method of NSString. I'll leave it to you to open the documentation and find it.

erritikamathur
Nov 26, 2009, 11:49 PM
I m aware that we can't use few characters in URL,so i m sending encoded URlL only by converting string url into URL by method [NSURL URLWithString:sender]

then also i m not able to download mp3 file.
if in case i send path for any other type of file i can easily download it my same method.

dejo
Nov 27, 2009, 11:03 AM
Does your NSError report any issues?