2014-06-06 31 views
1

我正在處理一個應用程序,在該應用程序中我從iPhone上的Dropbox上多個圖像。 當我上傳我的圖片時,我一次只上傳5張圖片,無論我選擇5張還是超過5張圖片。 下面是我對日誌我得到下面的錯誤::從我的IOS應用程序上傳Dropbox上的多個圖像

2014年6月6日15對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]; 

    [email protected]"Please wait for Uploading"; 
    HUD.dimBackground=YES; 
    [HUD show:YES]; 

    //NSString *[email protected]"/%@",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]; 

} 

上傳圖片代碼:51:55.977 PicBackMan_1 [3499:60B] [警告] DropboxSDK:向/1/files_put/dropbox/Like-2/PicBackMan-12.jpg發出錯誤請求 - (-1005)錯誤域= NSURLErrorDomain代碼= -1005「操作無法完成(NSURLErrorDomain錯誤)「UserInfo = 0xa5d4570 {destinationPath =/Like-2/PicBackMan-12.jpg,sourcePath =/Users/bettermac9/Library/Application Support/iPhone Simulator/7.1/Applications/F51F7F8F-91C5-4E67-90E6-4218941D3A67 /Documents/image.jpg}

2014年6月6日15:51:56.500 PicBackMan_1 [3499:60B] [警告] DropboxSDK:錯誤使請求/ 1 /元數據/保管箱/照片 - (404)路徑 '/照片' 未找到

2014-06-06 15:51:56.500 PicBackMan_1 [3499:60b] restClient:loadMetadataFailedWithError:操作無法完成。 (dropbox.com錯誤404)

我不明白爲什麼有連接超時? 上傳到Dropbox上的照片,其中一些未正確存儲,並且圖像未顯示錯誤。 請幫助我解決更好的問題。

感謝您寶貴的時間。

回答

0

嘗試序列化您的上傳,而不是試圖一次完成所有操作。對於某些操作(如上傳文件),Dropbox必須將服務器上的寫入序列化,因此即使您一次啓動五次上載,也只能一次實際處理一次。您嘗試同時執行的上傳次數越多,越有可能在後面的時間在等待時超時。

+0

@smaarx:尊敬的先生,謝謝你的建議。我可以請你告訴我,我如何序列化我的上傳在iOS應用程序。我從過去2個月的iOS應用程序開發工作,所以我不知道如何做到這一點。請讓我知道,謝謝 – bettermab9

相關問題