首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从我的IOS应用程序上传多个镜像到Dropbox

从我的IOS应用程序上传多个镜像到Dropbox
EN

Stack Overflow用户
提问于 2014-06-06 18:38:57
回答 1查看 451关注 0票数 1

我正在开发一个应用程序,在这个应用程序中,我从IPhone上传了多张图片到Dropbox上。当我上传我的图片时,一次只上传5张图片,无论我选择5张还是5张以上。下面是我在Dropbox上传图片的代码:

代码语言:javascript
复制
- (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的照片,其中一些没有正确存储,图像不能查看错误。请帮我找出更好的解决方案。

感谢您的宝贵时间。

EN

回答 1

Stack Overflow用户

发布于 2014-06-06 23:39:39

尝试序列化你的上传,而不是试图一次完成所有的上传。对于一些操作(比如上传文件),Dropbox必须在服务器上序列化写入,所以即使你一次开始五次上传,实际上一次也只会处理一次。同时尝试上传的内容越多,后面的上传就越有可能在等待时超时。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24079821

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档