问题描述
我正在尝试将图像上传到保管箱。我正在使用最新版本的SDK(9月17日),并且已经成功验证了我的应用。
I'm trying to upload an image to dropbox. I'm using the latest version of the SDK (Sept. 17) and have successfully authenticated my app.
以下是执行该操作的代码:
Here's the code that does it:
for ( NSUInteger i = 0; i < [photos count]; i ++ ) {
NSString *filename = [NSString stringWithFormat:@"%d.png", i+1];
NSString *file = [NSTemporaryDirectory() stringByAppendingPathComponent:filename];
[UIImagePNGRepresentation([photos objectAtIndex:i]) writeToFile:file atomically:YES];
NSString *destDir = @"/";
[self.dropboxClient uploadFile:filename toPath:destDir withParentRev:nil fromPath:file];
}
注意:
-
self.dropboxClient
是实例化的DBRestClient
对象。 -
照片
是UIImages的NSMutableArray(我已经使用NSStringFromClass()方法对对象进行了检查,以确保对象是图像。列表);
self.dropboxClient
is an instancedDBRestClient
object.photos
is an NSMutableArray of UIImages (I already checked to make sure that the objects are images using the NSStringFromClass() method on each object in the list);
最重要的是,我认为我的 DBRestClient 对象(
self.dropboxClient
),因为即使我设置了委托也没有输入任何委托方法。
Most importantly, I think there may be an issue with my
DBRestClient
object (self.dropboxClient
), since none of the delegate methods are entered even though I've set the delegate.
任何帮助都将不胜感激!
Any and all help would be greatly appreciated!
推荐答案
这是一个线程问题。必须在主线程上执行DBRestClient方法,例如
createFolder
和 uploadFile ::::
。
This was a threading issue. DBRestClient methods, like
createFolder
and uploadFile::::
must be executed on the main thread.
这篇关于将图像上传到Dropbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!