I am trying to implement an IOS application. The need of my application is to access the documents(pdf,photo etc) from DropBox Application(My iphone has DropBox Application ) .I am new in iphone development ,so i have no idea about access the document from DropBox.
If anybody know please help me . Thanks in advance.
First, you will need official Dropbox iOS SDK. Next, you will need an application key, which you can obtain from Dropbox website (choose MyApps). You will notice that the Dropbox iOS SDK comes with a bundled demo application, so have a look there. Also, good starting tutorial can be found here.
To access a file, your code will look something like:
NSString* consumerKey; //fill your key
NSString* consumerSecret ; //fill your secret
DBSession* session = [[DBSession alloc] initWithConsumerKey:consumerKey
consumerSecret:consumerSecret];
session.delegate = self;
[DBSession setSharedSession:session];
[session release];
if (![[DBSession sharedSession] isLinked])
{
DBLoginController* controller = [[DBLoginController new] autorelease];
controller.delegate = self;
[controller presentFromController:self];
}
DBRestClient *rc = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
self.restClient = rc;
[rc release];
self.restClient.delegate = self;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"SampleFile.txt"];
[self.restClient loadFile:@"/example/SampleFile.txt" intoPath:filePath];
Please note that iOS Dropbox SDK requires iOS 4.2 or greater.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With