将内存中的 UIimage 上传到 iOS 中的 Dropbox
我想将我的应用程序生成的图像上传到 Dropbox。我看到来自 DBRestClient 的上传方法,但在我看来,我必须在调用上传方法之前将图像写入临时文件。
有没有办法从内存中的对象上传文件?像这样的东西:
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];
I want to upload an image generated by my app to Dropbox. I see the upload method from DBRestClient, but it seems to me that I have to write the Image to a temp file before calling the upload method.
Is there any way to upload file from an object in memory? Something like this:
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];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
DBRestClient 的标头仅显示
iPhone 有磁盘,因此使用给定方法将图像上传为 tmp 文件,然后删除它?您可以使用 writeToFile:atomically: 或 writeToFile:options:error: of NSData 用于此目的。
The header of DBRestClient does only reveal
The iPhone has a disk, so upload your image as tmp file with the given method and delete it afterwards? You can use writeToFile:atomically: or writeToFile:options:error: of NSData for that purpose.
这就是我实现解决方案的方式:
That's the way I implemented the solution: