我想选择图片到图库和我要在dropbox上传的图片。我该怎么做?
我尝试过Dropbox SDK,但我不知道如何上传所选图片
- (void)uploadFile:(NSString*)filename toPath:(NSString*)path fromPath:(NSString *)sourcePath
此方法在DBRestClient.h
中定义,DropBox SDK
是来自// AND
let hi (NonEmptyString _ & StartsWithX s) = printfn "Hi %s" s
for iOS的库文件。但是从上面的方法声明中," fromPath"需要确定UIImageView中存在的图像,以便将其上传到我在Dropbox上的帐户。能否帮助我确定如何确定路径,或者就此而言,可以适用的任何工作。
答案 0 :(得分:1)
Here是如何实现这一目标的教程。这是几个步骤,很难说出你做错了什么,这就是为什么我只包含一个答案的链接。
但基本上
let uploadTextFileAction = UIAlertAction(title: "Upload text file", style: UIAlertActionStyle.Default) { (action) -> Void in
let uploadFilename = "testtext.txt"
let sourcePath = NSBundle.mainBundle().pathForResource("testtext", ofType: "txt")
let destinationPath = "/"
self.dbRestClient.uploadFile(uploadFilename, toPath: destinationPath, withParentRev: nil, fromPath: sourcePath)
}
我建议你查看教程,因为有一些框架导入和其他所需的东西。
答案 1 :(得分:1)
NSData *data = UIImagePNGRepresentation(imageView.image);
NSString *file = [NSTemporaryDirectory() stringByAppendingPathComponent:@"upload.png"];
[data writeToFile:file atomically:YES];
[DBRestClient uploadFile:@"upload.png" toPath:@"Dropbox/Path" fromPath:file];