【问题标题】:Uploading multiple images on Dropbox from my IOS application从我的 IOS 应用程序在 Dropbox 上上传多个图像
【发布时间】: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 的照片,其中一些未正确存储,出现图像无法查看错误。 请帮助我找到更好的解决方案。

感谢您宝贵的时间。

【问题讨论】:

    标签: ios iphone dropbox


    【解决方案1】:

    尝试序列化您的上传,而不是一次全部完成。对于某些操作(例如上传文件),Dropbox 必须对服务器上的写入进行序列化,因此即使您一次启动五次上传,实际上一次只会处理一次。您尝试同时进行的上传越多,后面的上传越有可能在等待时超时。

    【讨论】:

    • @smaarx:尊敬的先生,谢谢您的好意建议。先生,您能告诉我如何在 IOS 应用程序中序列化我的上传内容。我从过去 2 个月开始从事 IOS 应用程序开发工作,所以我不知道该怎么做。所以请告诉我。谢谢
    猜你喜欢
    • 1970-01-01
    • 2013-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-20
    相关资源
    最近更新 更多