如何使用iOS DropBox SDK将照片上传到DropBox。我尝试使用以下代码:
NSData *datobj = UIImagePNGRepresentation(uploadPhoto.image);
NSString *stringConvertion = [[NSString alloc] initWithData:datobj encoding:NSUTF8StringEncoding];
NSString *filename = stringConvertion;
NSString *destDir = @"/";
[[self restClient] uploadFile:filename toPath:destDir
withParentRev:nil fromPath:stringConvertion];
但我收到以下回复:[警告] DropboxSDK:文件不存在((null))
答案 0 :(得分:1)
您正在尝试根据图像的PNG数据创建一个字符串。注意
UIImagePNGRepresentation()
不返回文件名 - 它返回一个NSData对象,其字节代表原始PNG数据。
试试这个:
NSString *tmpPngFile = [NSTemporaryDirectory() stringByAppendingPathComponent:@"Temp.png"];
[UIImagePNGRepresentation(uploadPhoto.image) writeToFile:tmpPngFile atomically:NO];
NSString *destDir = @"/";
[[self restClient] uploadFile:filename toPath:destDir
withParentRev:nil fromPath:tmpPngName];