我正在开发一个IOS应用程序,我必须在DropBox上传图像,但是当我在iPhone模拟器上上传图像时,只上传了5-6张图像,我遇到了连接超时等问题(-1005) ),网络错误总是 - >
2014-06-10 11:42:53.283 PicBackMan_1[2602:60b] [WARNING] DropboxSDK: error making request to /1/metadata/dropbox/Photos - (404) Path '/Photos' not found
2014-06-10 11:42:53.285 PicBackMan_1[2602:60b] restClient:loadMetadataFailedWithError: The operation couldn’t be completed. (dropbox.com error 404.)
2014-06-10 11:42:55.167 PicBackMan_1[2602:60b] [WARNING] DropboxSDK: error making request to /1/files_put/dropbox/Super_12/PicBackMan-41.jpg - (-1005) Error Domain=NSURLErrorDomain Code=-1005 "The operation couldn’t be completed. (NSURLErrorDomain error -1005.)" UserInfo=0xa53b1d0 {destinationPath=/Super_12/PicBackMan-41.jpg, sourcePath=/Users/bettermac9/Library/Application Support/iPhone Simulator/7.1/Applications/F51F7F8F-91C5-4E67-90E6-4218941D3A67/Documents/image.jpg}
我收到这些类型的各种错误。我的iPhone模拟器有任何问题。它能在iPhone设备上正常工作吗? 请帮帮我。
我在DropBox上传图片的代码
- (void)_startUpload:(UIImage *)image
{
UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
NSLog(@"%@",(NSString*)countere);
}];
// while(countere != 0){
HUD=[[MBProgressHUD alloc]initWithView:self.view];
[self.view addSubview:HUD];
HUD.labelText=@"Please wait for Uploading";
HUD.dimBackground=YES;
[HUD show:YES];
//NSString *fileString=@"/%@",albumNAME;
// NSData * JPEGData = UIImageJPEGRepresentation(image, 1.0);
self.file = [NSString stringWithFormat:@"/%@",albumNAME];
NSLog(@"File Name ---> %@",self.file);
NSInteger randomNumber = arc4random() % 100;
NSString *filename = [NSString stringWithFormat:@"PicBackMan-%ld.jpg",(long)randomNumber];
NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask,
YES);
countere--;
NSString *localPath = [[pathList objectAtIndex:0] stringByAppendingPathComponent:@"image.jpg"];;
NSLog(@"local Path ----> %@",localPath);
NSString *destDir = self.file;
count4++;
// [presenter presentHud:@"Uploading"];
[[self restClient] uploadFile:filename toPath:destDir
withParentRev:nil fromPath:localPath];
if (count4%4==0) {
[NSThread sleepForTimeInterval:2];
NSLog(@"Background Thread Running");
}
//[NSThread sleepForTimeInterval:0.5];
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
// }
[self performSelectorOnMainThread:@selector(savingDone) withObject:nil waitUntilDone:YES];
}
答案 0 :(得分:0)
使用操作队列来限制并发上载的数量。或者,使用NSURLSessionUploadTask
,并在HTTPMaximumConnectionsPerHost
上设置NSURLSessionConfiguration
。