2

使用 SDK 将图像上传到文件夹我想获取图像的原始链接。我已经使用以下方法从 DMMetaData 中搜索了元数据。DBMetaData 拥有多种方法,例如“root”和“content”,但我总是收到 Null 响应。如果有人能引导我朝着正确的方向从响应中获取该信息,将不胜感激!

-(void)uploadImage:(UIImage *)image{

[sounds PlayUploading:nil];

NSLog(@"upload from uploader!~");
NSData *data = UIImagePNGRepresentation(image);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingString:@"PreviewMaker.png"];

[restClient setDelegate:self];


[data writeToFile:path atomically:YES];
[[self restClient] uploadFile:@"PreviewMaker.png" toPath:@"/"
                withParentRev:nil fromPath:path]; 



 }


 -(void)restClient:(DBRestClient *)client uploadedFile:(NSString *)destPath 
 from:(NSString *)srcPath metadata:(DBMetadata *)metadata{

 NSLog(@"uploaded: %@ from %@ withData %@",destPath,srcPath,metadata.root);

}
4

1 回答 1

10

在 DropBox 中获取文件的可共享链接!

DBRESTClient.h 中有一个方法,你应该看看!

- (void)loadSharableLinkForFile:(NSString *)path;

以及他们的委托方法!!

- (void)restClient:(DBRestClient*)restClient loadedSharableLink:(NSString*)link 
forFile:(NSString*)path;
- (void)restClient:(DBRestClient*)restClient loadSharableLinkFailedWithError:(NSError*)error;

示例:让我们考虑一下我的 Dropbox 中有一个文件 MyContacts 然后共享它,

[[self restClient] loadSharableLinkForFile:@"/MyContacts"];

及其委托方法

- (void)restClient:(DBRestClient*)restClient loadedSharableLink:(NSString*)link 
           forFile:(NSString*)path
{

    NSLog(@"Sharable link %@",link);
    NSLog(@"File Path %@ ",path);
}

- (void)restClient:(DBRestClient*)restClient loadSharableLinkFailedWithError:(NSError*)error
{
    NSLog(@"Error %@",error);
}
于 2012-05-12T13:35:32.197 回答