iOS使用ASIHttpRequest下载MP3文件

时间:2014-01-06 12:35:15

标签: ios asihttprequest

我正在开发一个应用程序,在该应用程序中,我们通过使用TFHpple解析其HTML内容从UIwebview中选择mp3 URL。 mp3网址是编码网址,即它们包含%20而不是空格。当我尝试使用ASIHttpRequest下载该mp3文件时,它会导致请求失败。请帮帮我

示例网址: http://www.tamilv2.com/Download%20SPL%20Collections/Voice%20of%20AR%20Rahman%20Songs/Aayutha%20Ezhuthu%20-%20Sandai%20Kozhi.mp3

我使用的代码:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"MyFolder"];
NSError *error = nil;
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
    [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error];
dwnldSongWebservice = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:SONG_URL_2]];
[dwnldSongWebservice setDownloadDestinationPath:[NSString stringWithFormat:@"%@/sample.mp3",dataPath]];
[dwnldSongWebservice setDelegate:self];
[dwnldSongWebservice startAsynchronous];

0 个答案:

没有答案