我正在使用ASIHTTPRequest在iOS7上传多个图像,我在上传大尺寸(每个4MB)图像时收到内存警告。我将转换base64编码中的所有图像并将服务器上的base64数据上传到上面。< / p>
这是我的代码:
-(void)UploadImages:(NSMutableDictionary *)dictdata
{
NSString *strURL = [NSString stringWithFormat:@“here is url ”];
NSURL* url = [[NSURL alloc] initWithString:strURL];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
for (int i = 0; i < [dicData count] ; i++) {
NSString *strKey = [[dicData allKeys] objectAtIndex:i];
NSString *strValue = [dicData objectForKey:strKey];
[request setPostValue:strValue forKey:strKey];
}
[request addRequestHeader:@"Content-Type" value:@"application/x-www-form-urlencoded"];
[request setUploadProgressDelegate:appDelegate.progressIndicator];
[request setUploadProgressDelegate:delegate];
[request setShouldStreamPostDataFromDisk:YES];
request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
request.showAccurateProgress = TRUE;
[request setDelegate:delegate];
[appDelegate.request setTimeOutSeconds:60000];
request.shouldAttemptPersistentConnection = NO;
[request setDidFinishSelector:@selector(uploadRequestFinished:)];
[request setDidFailSelector:@selector(uploadRequestFailed:)];
[request startAsynchronous];
}