我正在开发一个应用程序,在这个应用程序中,我从IPhone上传了多张图片到Dropbox上。当我上传我的图片时,一次只上传5张图片,无论我选择5张还是5张以上。下面是我在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;
// [presenter presentHud:@"Uploading"];
[[self restClient] uploadFile:filename toPath:destDir
withParentRev:nil fromPath:localPath];
//[NSThread sleepForTimeInterval:0.5];
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
// }
[self performSelectorOnMainThread:@selector(savingDone) withObject:nil waitUntilDone:YES];
}在日志中,我收到以下错误::
2014-06-06 15:51:55.977 PicBackMan_13499:60b DropboxSDK:请求/1/files_put/dropbox/Like-2/PicBackMan-12.jpg - (-1005)错误代码=-55.977错误代码=-1005“无法完成操作。(NSURLErrorDomain错误-1005。)”sourcePath=/Users/bettermac9/Library/Application {目标路径=/Like-2/ UserInfo=0xa5d4570 -12.jpg,iPhone支持/iPhone Simulator/7.1/Applications/F51F7F8F-91C5-4E67-90E6-4218941D3A67/Documents/image.jpg}
2014-06-06 15:51:56.500 PicBackMan_13499:60b DropboxSDK:向/1/metadata/dropbox/Photos发出请求时出错- (404)未找到路径'/Photos‘
2014-06-06 15:51:56.500 PicBackMan_13499:60b restClient:loadMetadataFailedWithError:操作无法完成。(dropbox.com错误404。)
我不明白为什么连接超时??上传到Dropbox的照片,其中一些没有正确存储,图像不能查看错误。请帮我找出更好的解决方案。
感谢您的宝贵时间。
发布于 2014-06-06 23:39:39
尝试序列化你的上传,而不是试图一次完成所有的上传。对于一些操作(比如上传文件),Dropbox必须在服务器上序列化写入,所以即使你一次开始五次上传,实际上一次也只会处理一次。同时尝试上传的内容越多,后面的上传就越有可能在等待时超时。
https://stackoverflow.com/questions/24079821
复制相似问题