我想将应用程序生成的图像上传到Dropbox。我从DBRestClient看到了上载方法,但是在我看来,我必须在调用上载方法之前将Image写入临时文件。

有什么方法可以从内存中的对象上载文件吗?像这样:

UIimage *myImage = [[UIImage alloc]....
//
// Here I create the image on my app
//
NSData *myData = UIImageJPEGRepresentation(myImage, 1.0);
DBRestClient *rc = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
self.restClient = rc;
[rc release];
self.restClient.delegate = self;
[self.restClient uploadFile:@"myImage.jpg" toPath:@"DropBoxPath" fromPath:myData];

最佳答案

DBRestClient的标头仅显示

/* Uploads a file that will be named filename to the given root/path on the server. It will upload
   the contents of the file at sourcePath */
- (void)uploadFile:(NSString*)filename toPath:(NSString*)path fromPath:(NSString *)sourcePath;

iPhone有磁盘,因此请使用给定的方法将图像上传为tmp文件,然后再将其删除?为此,您可以使用writeToFile:atomically:writeToFile:options:error:NSData

关于ios - 将内存中的UIimage上载到iOS中的Dropbox,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5409023/

10-13 03:57