GDCloudFileBrowser is an iOS drop-in wrapper class that can be used with existing or new projects to access a user's Dropbox or Google Drive content.
TLDR: Include QuartzCore, CoreGraphics, SystemConfiguration and Security.framework
- GDCloudFileBrowser is tested only for iOS 7 or above and will work only with ARC projects.
- GDCloudFileBrowser uses UIKit, CoreGraphics.
- GDCloudFileBrowser uses the DropboxSDK Core SDK last updated on Sep-15th-2014 (v1.3.13) which requires QuartzCore, Security.framework
- GDCloudFileBrowser uses the GTL google-api-objectivec-client last updated on Dec-6th-2012 which uses Security, SystemConfiguration.
- Run
pod install
to install Google Drive project
Download the Source project and drag and drop the contents of Core folder into your project. Run pod install
from your projects root folder.
Your View Controller must conform to the GDFilePickerDelegate
protocol to receive callbacks.
If you would like to see detailed logs, enable it in the GDLog.h file. Set ENABLE_LOG flag to YES
If you're using Dropbox update your app's Supported URL Schemes in your Info.plist file. Info.plist > URL Types > URL Schemes [db-APP_KEY replacing APP_KEY with the key generated when you created your app]
static NSString *const kDropboxClientId = @""; // Set the client Id from your Dropbox developer console and update the Info.plist (see above for instructions)
static NSString *const kDropboxClientSecret = @""; // Set the client Secret from your Dropbox developer console
static NSString *const kGoogleDriveClientId = @""; // Set the client Id from your Google developer console
static NSString *const kGoogleDriveClientSecret = @""; // Set the client Secret from your Google developer console
static NSString *const kGoogleDriveClientKeychainName = @""; // Set a name for the keychain entry
GDDropboxHelper *dropboxHelper = [[GDDropboxHelper alloc] initWithDelegate:self];
if (![self.dropboxHelper dropboxAccountLinked]) { // no accounts are currently linked.
[[DBSession sharedSession] linkFromController:self];
}
@property (nonatomic, copy) NSString *dropboxPath; // use `@"\"` to indicate root folder
[self.dropboxHelper downloadFilesFrom:self.dropboxPath completion:^(BOOL success, NSError *error) {
/* custom logic upon downloading the files */
}];
If it's the root folder (Read comments in GDFilePickerViewController
to find why it's done this way)
@property (nonatomic, strong) GDGoogleDriveHelper *googleDriveHelper;
self.googleDriveHelper = [GDGoogleDriveHelper sharedManager];
self.googleDriveHelper.delegate = self;
If it's not the root folder
@property (nonatomic, strong) GDGoogleDriveHelper *googleDriveHelper;
self.googleDriveHelper = [[GDGoogleDriveHelper alloc] init];
self.googleDriveHelper.delegate = self;
if (![self.googleDriveHelper driveAccessAuthorized]) {
[self.navigationController pushViewController:[self.googleDriveHelper authController] animated:YES];
}
@property (nonatomic, copy) NSString *gDrivePath; // use `@"root"` to indicate root folder
[self.googleDriveHelper downloadFilesFrom:self.gDrivePath completion:^(BOOL success, NSError *error) {
/* custom logic upon downloading the files */
}];
- (void)userSelectedDropboxFileWithURL:(NSString *)url data:(NSData *)fileData relativePath:(NSString *)relativePath name:(NSString *)fileName {
/* custom logic to handle user's file selection */
}
- (void)userSelectedGoogleDriveFileWithURL:(NSString *)url data:(NSData *)fileData name:(NSString *)fileName {
/* custom logic to handle user's file selection */
This code is distributed under the terms and conditions of the MIT license.