【发布时间】:2014-06-06 10:38:57
【问题描述】:
我正在开发一个应用程序,在该应用程序中,我从我的 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_1[3499:60b] [警告] DropboxSDK:向 /1/files_put/dropbox/Like-2/PicBackMan-12.jpg 发出请求时出错 - (-1005) 错误Domain=NSURLErrorDomain Code=-1005 "操作无法完成。(NSURLErrorDomain error -1005.)" UserInfo=0xa5d4570 {destinationPath=/Like-2/PicBackMan-12.jpg, sourcePath=/Users/bettermac9/Library/应用支持/iPhone模拟器/7.1/Applications/F51F7F8F-91C5-4E67-90E6-4218941D3A67/Documents/image.jpg}
2014-06-06 15:51:56.500 PicBackMan_1[3499:60b] [警告] DropboxSDK:向 /1/metadata/dropbox/Photos 发出请求时出错 - (404) 找不到路径“/Photos”
2014-06-06 15:51:56.500 PicBackMan_1[3499:60b] restClient:loadMetadataFailedWithError: 操作无法完成。 (dropbox.com 错误 404。)
我不明白为什么会有连接超时? 上传到 Dropbox 的照片,其中一些未正确存储,出现图像无法查看错误。 请帮助我找到更好的解决方案。
感谢您宝贵的时间。
【问题讨论】: