The easiest way to import content into your application. Filepicker.io
-
Software
- Built targeting iOS 4.3
- XCode 4
-
Frameworks
- AssetsLibrary.framework
- QuartzCore.framework
- CoreFoundation.framework
- MobileCoreServices.framework
- CoreGraphics.framework
- Foundation.framework
- UIKit.framework
-
Other Linked Libraries (You don't need to download these. Already installed.)
- AFNetworking (https://github.com/AFNetworking/AFNetworking/)
- JSONkit (https://github.com/johnezang/JSONKit/)
- MBProgressHUD (https://github.com/jdg/MBProgressHUD)
- PullRefreshTableViewController (Forked from: https://github.com/leah/PullToRefresh)
#import <FPPicker/FPPicker.h>
// To create the object
FPPickerController *fpController = [[FPPickerController alloc] init];
// Set the delegate
fpController.fpdelegate = self;
// Ask for specific data types. (Optional) Default is all files.
fpController.dataTypes = [NSArray arrayWithObjects:@"text/plain", nil];
// Select and order the sources (Optional) Default is all sources
fpController.sourceNames = [[NSArray alloc] initWithObjects: FPSourceImagesearch, FPSourceDropbox, nil];
// You can set some of the in built Camera properties as you would with UIImagePicker
fpController.allowsEditing = YES;
/* Control if we should upload or download the files for you.
* Default is yes.
* When a user selects a local file, we'll upload it and return a remote url
* When a user selects a remote file, we'll download it and return the filedata to you.
*/
//fpController.shouldUpload = NO;
//fpController.shouldDownload = NO;
// Display it.
[self presentViewController:fpController animated:YES completion:nil];
// To create the object
FPSaveController *fpSave = [[FPSaveController alloc] init];
// Set the delegate
fpSave.fpdelegate = self;
// Ask for specific data mimetypes. (Optional) Default is all files.
fpController.dataTypes = [NSArray arrayWithObjects:@"text/plain", nil];
// Select and order the sources (Optional) Default is all sources
//fpSave.sourceNames = [NSArray arrayWithObjects: FPSourceCamera, FPSourceCameraRoll, FPSourceDropbox, FPSourceFacebook, FPSourceGmail, FPSourceBox, FPSourceGithub, FPSourceGoogleDrive, FPSourceImagesearch, nil];
// Set the data and data type to be saved.
fpSave.data = [[NSData *alloc] init] ;
fpSave.dataType = @"text/plain";
//alternative: fpSave.dataExtension = @"txt"
//optional: propose the default file name
fpSave.proposedFilename = @"AwesomeFile";
// Display it.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
UIPopoverController *popoverControllerA = [UIPopoverController alloc];
// You can set the delegate of the popover to be the FPPicker if you want FPPicker to report
// when the popover has been dismissed as a cancel
popoverControllerA.delegate = fpSave;
self.popoverController = [popoverControllerA initWithContentViewController:fpSave];
popoverController.popoverContentSize = CGSizeMake(320, 520);
[popoverController presentPopoverFromRect:[sender frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
[self presentViewController:fpSave animated:YES completion:nil];
}
####FPPickerControllerDelegate
- (void)FPPickerController:(FPPickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;
- Keys in the info dictionary
- FPPickerControllerFilename
- the NSString of the filename
- e.g:
202342304.jpg
- FPPickerControllerMediaType
- the UTType of the file
- e.g:
public.image
- FPPickerControllerMediaURL
- The local location of the file.
- e.g:
assets-library://asset/asset.JPG?id=1000000001&ext=JPG
- FPPickerControllerRemoteURL
- The URL for the file.
- e.g: https://www.filepicker.io/api/file/we9f3kf93qls0)
- (When Possible) FPPickerControllerOriginalImage
- The UIImage
- e.g:
<UIImage: 0x8a37730>
- (When Possible) FPPickerControllerKey
- The S3 key if the developer has set up Amazon S3 account at Filepicker.io
- e.g: JENAoTrDSPGFMrdxMd2R_photo.jpg
- The S3 key if the developer has set up Amazon S3 account at Filepicker.io
- FPPickerControllerFilename
- (void)FPPickerController:(FPPickerController *)picker didPickMediaWithInfo:(NSDictionary *)info;
- Keys in the info dictionary
- (When Possible) FPPickerControllerThumbnailImage
- The UIImage
- e.g:
<UIImage: 0x8a37730>
- (void)FPPickerControllerDidCancel:(FPPickerController *)picker
####FPSaveControllerDelegate Methods
- (void)FPSaveControllerDidSave:(FPSaveController *)picker;
When the user chooses where to save.
- (void)FPSaveController:(FPSaveController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;
When the save action has completed.
- IMPORTANT NOTE: Info is an empty dictionary; nothing is being passed back
- (void)FPSaveControllerDidCancel:(FPSaveController *)picker;
####List of all sources:
- Complete Listing
- FPSourceCamera
- The Local Camera
- Open: "image/jpeg", "image/png"
- Save: nil
- FPSourceCameraRoll
- The Local Photos
- Open: "image/jpeg", "image/png", "video/quicktime"
- Save: "image/jpeg", "image/png"
- FPSourceDropbox
- www.dropbox.com
- Open: "*/*"
- Save: "*/*"
- FPSourceFacebook
- www.facebook.com
- Open: "image/jpeg"
- Save: "image/*"
- FPSourceGmail
- www.gmail.com
- Open: "*/*"
- Save: nil
- FPSourceBox
- www.box.com
- Open: "*/*"
- Save: "*/*"
- FPSourceGithub
- www.github.com
- Open: "*/*"
- Save: nil
- FPSourceGoogleDrive
- drive.google.com
- Open: "*/*"
- Save: "*/*"
- FPSourceImagesearch
- Flickr Public Domain Image Search
- Open: "image/jpeg"
- Save: nil
- FPSourceInstagram
- www.instagram.com
- Open: "image/jpeg"
- Save: nil
- FPSourceCamera
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No JSON parsing functionality available'
'NSInvalidArgumentException', reason: '-[UIImageView setImageWithURLRequest:placeholderImage:success:failure:]:
These are likely because JSONKit or AFNetworking are not linked. One fix for this is to add -all_load
to Build Settings/Other Linker Flags
. This will link the libraries that Filepicker needs.
You probabably are using AFNetworking. Since Filepicker depends on it, the compiler is adding AFNetworking twice and complaining. If you have a similar Duplicate symbol
issue, it may be that you are using JSONkit
or MBProgressHUD
.
While this issue seems to be solved for XCode 4.4 Developer Preview 5 and beyond, the solution is to use the filepicker library without external libraries, then adding your own.
This issue was present for v1.0.0, but should be fixed from now on. Please report this to ios@filepicker.io
It may be that you haven't set your apikey as it's checked the first time it's loaded.
- Go to www.filepicker.io and register.
- In your application's info.plist, add the following key/value:
Key: "Filepicker API Key"
Value: YOUR_API_KEY (that you got from registering)
Our ability to deliver mobile pages is partly dependent on the service itself. Some have no mobile page at all. Others examine the user agent string and return the iPad version, not a popover friendly one. I've had good luck changing my user-agent string for a couple services.
Add this to your AppDelegate.m
/*
* This makese the login screens look much nicer on iPad
*/
+ (void)initialize {
// Set user agent (the only problem is that we can't modify the User-Agent later in the program)
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3", @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
}
-
Get an API Key
- Go to Filepicker.io to register an account
- Api Keys are typically randomized and 20 characters long.
-
Insert the framework and bundle
- Download or clone the repository.
- Under
/library
, you'll findFPPicker.framework
andFPPicker.bundle
- Drag both into your project, typically in your framework folder
#import <FPPicker/FPPicker.h>
in yourviewController.h
or other file where you want to use it.
-
Settings
- In your application's info.plist, add the following key/value:
Key: "Filepicker API Key"
Value: YOUR_API_KEY (that you got from step 1)
-
Notes:
- If this doesn't build, I've had luck adding
-all_load -ObjC
inBuild_Settings/Other_Linker_Flags
- You may need to add additional frameworks
- AssetsLibrary.framework
- QuartzCore.framework
- CoreFoundation.framework
- MobileCoreServices.framework
- CoreGraphics.framework
- Foundation.framework
- UIKit.framework
- If this doesn't build, I've had luck adding
-
Use it
- Initialize it:
FPPickerController *fpController = [[FPPickerController alloc] init];
fpController.fpdelegate = self;
// - Delegate Methods:
- (void)FPPickerController:(FPPickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;
- (void)FPPickerControllerDidCancel:(FPPickerController *)picker;
-
Get an Api Key:
- Go to Filepicker.io to register an account
- Api Keys are typically randomized and 20 characters long.
-
Insert the framework and bundle:
- Download or clone the repository.
- Open the
/Examples/FPDemo.xcodeproj
-
Settings:
- In your application's info.plist, add the following key/value:
Key: "Filepicker API Key"
Value: YOUR_API_KEY (that you got from step 1)
- Build and Run
-
Get an Api Key:
- Go to Filepicker.io to register an account
- Api Keys are typically randomized and 20 characters long.
-
- File/New/Project or Shift-Apple N
- Single View Project
- Name: FilepickerDemo - Device Family: iPad - Use Storyboards: False - Use Automatic Reference Counting: True
-
Insert the framework and bundle
- Download or clone the repository.
- You can do this at the top of this git repository with either `ZIP` to get the zip or `git clone https://github.com/Filepicker/ios.git`. - Open up the folder. - Under `library/`, you'll find `FPPicker.framework` and `FPPicker.bundle`
- Drag both into your project, typically in your framework folder
- Choose to `Copy items into Destination Folder`
-
Adding Additional Frameworks
- Click on the .xcodeProj
- Under `Build Phases -> Link Binary with Libraries`, add the following: - AssetsLibrary.framework - QuartzCore.framework - CoreGraphics.framework - MobileCoreServices.framework - Foundation.framework - CoreFoundation.framework
- Under `Build Settings`, search for `Other Linker Flags` and set it to -all_load
-
Write the code
- You can copy and paste the following code into your
ViewController.h
andViewController.m
respectively. - In
ViewController.h
- We create a button, imageview, and a popover
- In
ViewController.m
- We create an action when the button is pressed
- We also have two delegates that respond when the Filepicker is finished.
- ViewController.h Source
- ViewController.m Source
- You can copy and paste the following code into your
-
Build the User Interface
- Drag a 'Image View' and a 'Rounded Rectangle Button' from the objects draw on the right.
- Hook up the proper interfaces - On the right hand side, you'll notice three icons, one of which is the `File's Owner`
- Hold down Ctrl, click and hold down the File Owner Orange Cube, then drag to the Image. A small popup will ask you to connect the file owner to the image. Choose `Outlet: Image`. - In a similar manner, ctrl drag from File Owner -> Button. Choose `Outlet: Button`. - Now, in the opposite direction, ctrl dragging from the button to the file owner. Choose `pickerAction:`. - Now if you right click on file owner, you should see the following.
-
Add your API Key
- Go to
Supporting Files/FilepickerDemo-Info.plist
. (Your's may vary if you didn't name it FilepickerDemo). - Right click,
Add Row
. - For the key:
Filepicker API Key
- For the value, paste in your apikey that you got from filepicker.io
- Go to
-
Run.
- Click the
run
button in the upper right corner of xcode. - It should build and you can now choose a file!
- Click the