Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

iphone - GET URL link from uploaded image to dropbox with SDK

Uploading images to a folder using the SDK I would like to get the original link to the image. I have searched the the metaData from DMMetaData using the method below. There are several methods owned by DBMetaData such as "root" and "content" but I always recieve a Null response. If anyone could possibly lead me in the right direction to grab that information from the response that would be greatly appreciated!

-(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);

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To get a sharable link for a file in DropBox !

There is a method in DBRestClient.h that you should take a look at!

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

and their delegate Methods as well!!

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

example : let us consider i have a file MyContacts in my Dropbox then to share it ,

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

and their delegate methods

- (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);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...