大家好我从亚马逊s3网址下载文件时出现问题:
?https://s3.amazonaws.com:443/ [东西] / [文件名] .MP3签名= [签名]&安培;到期= [到期]&安培; AWSAccessKeyId = [ACCESSID]
以上网址只是一种格式,并且是保密的,因此我无法发布实际的网址。
我使用ASIHTTPRequest下载文件,但获取http状态代码403(禁止)和响应字符串为null。
当我将链接粘贴到网络浏览器的地址栏中时,浏览器会播放歌曲。
这是代码:
if (!networkQueue) {
networkQueue = [ASINetworkQueue queue];
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
ASIHTTPRequest *downloadRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:[mediaUrlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ]];
[downloadRequest setRequestMethod:@"GET"];
[downloadRequest setShouldRedirect:YES];
NSString *fileName = [NSString stringWithFormat:@"%@.mp3",[dict valueForKey:@"ID"]];
fileName = [fileName stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *filePath = [NSString stringWithFormat:@"%@/%@",documentsDirectory,fileName];
NSLog(@"File Path: %@",filePath);
[downloadRequest setDownloadDestinationPath:filePath];
[downloadRequest setDownloadProgressDelegate:[downloadView viewWithTag:2]];
[downloadRequest setDelegate:self];
[downloadRequest setDidFinishSelector:@selector(downloadFinished:)];
[downloadRequest setDidFailSelector:@selector(downloadFailed:)];
[networkQueue addOperation:downloadRequest];
[networkQueue go];
是否可以使用amazon s3 url下载文件具有上述格式。如果有,怎么样? 在此先感谢您的帮助