Coder Social home page Coder Social logo

xiebohui2013 / gdfilemanagerkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grahamdennis/gdfilemanagerkit

0.0 2.0 0.0 715 KB

A consistent iOS API for cloud file storage services including Dropbox and Google Drive.

License: MIT License

gdfilemanagerkit's Introduction

GDFileManagerKit

Version Platform

Fed up with different/inconsistent/non-existent SDKs for cloud file storage services? Try GDFileManagerKit! GDFileManagerKit lets you access Dropbox, Google Drive, SugarSync and WebDAV with a consistent, NSFileManager-like API.

Features of GDFileManagerKit include:

  • Persistent cached file metadata. Old metadata is re-validated where possible making API calls more efficient.
  • Cached file downloads.
  • Chunked upload / downloads where available for reliability in intermittently connected environments.
  • Copy/Delete/Move file operations.
  • Aliases to keep track of files if the user moves / renames them remotely (requires a file service that supports persistent file identifiers like Google Drive or SugarSync).

GDFileManagerKit is currently beta-quality software, but I am using it in my app PocketBib.

Screenshots

File service list. To add an account, tap the 'plus' button. FileServiceList

Adding an account...

AddAccount

Downloading a file. (To upload a test file, tap the 'plus' button in the left navigation bar).

DownloadingFile

Usage

Get the contents of a directory:

[[GDFileManager sharedManager] getContentsOfDirectoryAtURL:url success:^(NSArray *contents) {
    for (GDURLMetadata *metadata in contents) {
        NSLog(@"Found %@ called \"%@\"", [metadata isDirectory] ? @"folder" : @"file", metadata.filename);
    }

} failure:^(NSError *error) {
    NSLog(@"error: %@", error);
}];

Check the local cache for the file, download it if it has been updated, and cache the result:

GDFileManager *fileManager = [GDFileManager new];
GDFileManagerDownloadOperation *downloadOperation = [fileManager cachedDownloadOperationFromSourceURL:url
                                                                   success:^(NSURL *localURL, GDURLMetadata *metadata) {
                                                                       NSLog(@"success: %@; metadata = %@", localURL, metadata);
                                                                   } failure:^(NSError *error) {
                                                                       if ([[error domain] isEqualToString:NSURLErrorDomain] && [error code] == NSURLErrorCancelled) {
                                                                       } else
                                                                           NSLog(@"download failed: %@", error);
                                                                   }];
[fileManager enqueueFileManagerOperation:downloadOperation];

To set your Dropbox API key:

[GDDropboxAPIToken registerTokenWithKey:@"<dropbox_key>"
                                 secret:@"<dropbox_secret>"
                                   root:GDDropboxRootDropbox]; // This token has access to the entire dropbox folder

See the included GDFileManagerExample for more examples. To run the demo app, run pod install, and then open GDFileManagerExample.xcworkspace and build.

Requirements

iOS 5.0+, uses a number of external libraries including AFNetworking 1.x, SSKeychain, AFOAuth2Client.

Installation

GDFileManagerKit is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "GDFileManagerKit"

Author

Graham Dennis, [email protected]

License

GDFileManagerKit is available under the MIT license. See the LICENSE file for more info. If you require a non-attribution license, please contact me at [email protected]

gdfilemanagerkit's People

Contributors

grahamdennis avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.