0
我有一個iPhone應用程序,我希望將手機本地磁盤上的文件上傳到用戶的保管箱。我想給用戶一個選項,將其上傳到他的Dropbox的任何地方。我看到很多應用程序都這樣做,但還沒有找到任何在線示例,它使我通過一步一步的教程。任何指針都會有幫助!將文件上傳到Dropbox中的特定文件夾
編輯:
//setup
DBSession* dbSession = [[DBSession alloc] initWithAppKey:@"XXX"
appSecret:@"XXX"
root:kDBRootDropbox];
[DBSession setSharedSession:dbSession];
[self handleDropboxSession];
DBRestClient *restclient = [[DBRestClient alloc] initWithSession:dbSession];
restclient.delegate = self;
[NSTimer scheduledTimerWithTimeInterval:5.0f block:^{
[self testSaveFileToDBox:restclient];
} repeats:NO];
//relevant methods
-(void)testSaveFileToDBox:(DBRestClient *)client
{
NSString *localPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
NSString *filename = @"working-draft.txt";
NSString *destDir = @"/";
[client uploadFile:filename toPath:destDir
withParentRev:nil fromPath:localPath];
}
- (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath
from:(NSString*)srcPath metadata:(DBMetadata*)metadata {
NSLog(@"File uploaded successfully to path: %@", metadata.path);
}
- (void)restClient:(DBRestClient*)client uploadFileFailedWithError:(NSError*)error {
NSLog(@"File upload failed with error - %@", error);
}
-(void)restClient:(DBRestClient *)client uploadProgress:(CGFloat)progress forFile:(NSString *)destPath from:(NSString *)srcPath{
NSLog(@"upload progress");
}
文件「工薪draft.txt」並不存在,但那麼錯誤的委託方法是沒有得到調用。 FWIW,這一切都在應用程序代表。
顯示您的相關代碼,您將努力將文件上傳到Dropbox。 – rmaddy
@rmaddy編輯代碼示例 –
順便說一句,我發現https://github.com/goosoftware/GSDropboxActivity這是非常相似。如果你知道有什麼更好的,讓我知道! –