Dropbox restClient 只保存文件。所以我想先将图像保存在本地文件夹中,然后再上传它,结果它保存了文件,但它已损坏。
NSString *localPath = [[NSBundle mainBundle] pathForResource"Info" ofType"plist"];
NSString *jpegFilePath = [NSString stringWithFormat"%@/test.jpeg",localPath];
NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];
[data2 writeToFile:jpegFilePath atomically:YES];
NSString *filename = @"test.jpeg";
NSString *destDir = @"/";
[[self restClient] uploadFile:filename toPath:destDir
withParentRev:nil fromPath:localPath];
我是个白痴,解决了
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingString"test.jpg"];
NSData * data = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];
[data writeToFile:path atomically:YES];
[self.restClient uploadFile"test.jpg" toPath"/" withParentRev:nil fromPath:path];
Best Answer-推荐答案 strong>
您必须从主线程或具有运行循环的线程调用 DBResClient 方法。否则不会调用委托(delegate)方法。
您需要做的是首先分配初始化 yoir DBRESTClient 对象,然后将其设置为委托(delegate)自身,然后您就可以轻松上传您的文件。下面是一个示例
NSString *destDir = @"/";
restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
restClient.delegate = self;
[restClient uploadFile:yourfilename toPath:destDir withParentRev:nil fromPath:sourcepath];
编码愉快!!!!!!
关于objective-c - 如何将设备上未保存的图像上传到保管箱帐户?(IOS),我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/8985084/
|