TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jun 2017 |
Maintained by Filestack iOS.
Depends on: | |
Filestack | >= 0 |
GTMAppAuth | >= 0 |
GoogleAPIClientForREST | >= 0 |
GoogleAPIClientForREST/Drive | >= 0 |
GoogleAPIClientForREST/Gmail | >= 0 |
FSPicker is a Filestack's reimplementation of iOS-picker. If you have any feature request or bug to report, please open an issue or PR.
iOS 8.4 or later
To begin using FSPicker you need to import the module:
#import <FSPicker/FSPicker.h>
// or
@import FSPicker;
To integrate Google Services and Google SignIn please readGoogleServicesIntegration
Initialize config, (optionally theme and store options) and finally FSPickerController:
FSConfig *config = [[FSConfig alloc] initWithApiKey:@"YOUR_API_KEY"];
FSStoreOptions *storeOptions = [[FSStoreOptions alloc] init];
storeOptions.location = FSStoreLocationS3;
config.storeOptions = storeOptions;
FSTheme *theme = [FSTheme filestackTheme];
FSPickerController *fsPickerController = [[FSPickerController alloc] initWithConfig:config theme:theme];
fsPickerController.fsDelegate = self;
// present the controller
[self presentViewController:fsPickerController animated:YES completion:nil];
// Or for FSSaveController
// configure the data
NSString *testImagePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"png"];
NSURL *testImageURL = [NSURL URLWithString:testImagePath];
config.dataMimeType = FSMimeTypeImagePNG;
config.localDataURL = testImageURL;
config.proposedFileName = @"newimage";
// present the controller
FSSaveController *fsSaveController = [[FSSaveController alloc] initWithConfig:config theme:theme];
fsSaveController.fsDelegate = self;
[self presentViewController:fsSaveController animated:YES completion:nil];
// Called when user dismisses the picker controller.
- (void)fsPickerDidCancel:(FSPickerController *)picker;
// Called when picking of a single file resulted in error.
// This does not mean that picking of the rest of the files (in case of multiple files available) is interrupted.
// All files of multiple files pick, that resulted in error will call this method.
- (void)fsPicker:(FSPickerController *)picker pickingDidError:(NSError *)error;
// Called when picking of a single file completed with success.
// If you are picking multiple files this will be called for each of successfully picked file.
- (void)fsPicker:(FSPickerController *)picker pickedMediaWithBlob:(FSBlob *)blob;
// Called when "files picking" is finished. Blobs array will contain blobs of all successfully picked files.
- (void)fsPicker:(FSPickerController *)picker didFinishPickingMediaWithBlobs:(NSArray<FSBlob *> *)blobs;
// Called when user dismisses the save controller.
- (void)fsSaveControllerDidCancel:(FSSaveController *)saveController;
// Called when saving of data resulted in error.
- (void)fsSaveController:(FSSaveController *)saveController savingDidError:(NSError *)error;
// Called when saving of data completed with success.
- (void)fsSaveController:(FSSaveController *)saveController didFinishSavingMediaWithBlob:(FSBlob *)blob;
NSString *apiKey;
NSString *title;
NSArray<NSString *> *sources;
// FSPickerController
NSArray<FSMimeType> *mimeTypes;
NSInteger maxFiles;
NSUInteger maxSize;
BOOL selectMultiple;
BOOL defaultToFrontCamera;
BOOL shouldDownload;
// BOOL shouldUpload; TODO
FSStoreOptions *storeOptions;
// FSSaveController
NSData *data;
NSURL *localDataURL;
FSMimeType dataMimeType;
NSString *dataExtension;
NSString *proposedFileName;
The most important property is apiKey
also it is the only property you need to provide for FSPicker to actually work. You can find your application's api key in developer portal.
title
sets navigation bar title of FSPickerController/FSSaveController. Defaults to "Filestack".
sources
array allows you to configure sources you'd like to have available in your application. You can find sources names below. If no or empty array is set - all sources are displayed on the list.
mimeTypes
array is used to constraining displayed files to certain types. There are typedefs defined for your convenience. If this property is not provided all file types will be available for uploading (/).
selectMultiple
YES by default. If set to NO, FSPicker will automatically "pick" file on select.
defaultToFrontCamera
- set to YES if you want to open "Camera" source with front camera as default.
maxFiles
sets maximum number of files to upload simultaneously. Unlimited by default.
maxSize
Limit upload file size to be at most maxSize, specified in bytes. By default file size is not limited. If specified, files larger than maxSize won't be displayed in PickerController.
shouldDownload
After picking a file with PickerController, the file is downloaded to device's temp storage. Path is available at FSBlob's internalURL
property.
shouldUpload
#TODO
storeOptions
FSStoreOptions
data
Data to export. You should have either this property or localDataURL
property set, to be able to use FSSaveController.
localDataURL
URL to local data. You should have either this property or data
property set, to be able to use FSSaveController.
dataMimeType
Mimetype of the data you'd like to export. This setting is not required, but it is highly recommended to provide it or provide dataExtension
.
dataExtension
Extension of the data you'd like to export. You can use it interchangeably with dataMimeType
.
proposedFileName
File name that will be set in "file name field". This should be without extension. If no name is provided, end user will be required to provide it.
FSSourceBox
FSSourceCameraRoll
FSSourceDropbox
FSSourceFacebook
FSSourceGithub
FSSourceGmail
FSSourceImageSearch
FSSourceCamera
FSSourceGoogleDrive
FSSourceInstagram
FSSourceFlickr
FSSourcePicasa
FSSourceSkydrive
FSSourceEvernote
FSSourceCloudDrive
typedef NSString * FSMimeType;
FSMimeTypeAll @"*/*"
FSMimeTypeAudioAll @"audio/*"
FSMimeTypeVideoAll @"video/*"
FSMimeTypeVideoQuickTime @"video/quicktime"
FSMimeTypeImageAll @"image/*"
FSMimeTypeImagePNG @"image/png"
FSMimeTypeImageJPEG @"image/jpeg"
FSMimeTypeImageBMP @"image/bmp"
FSMimeTypeImageGIF @"image/gif"
FSMimeTypeImageSVG @"image/svg+xml"
FSMimeTypeImageTIFF @"image/tiff"
FSMimeTypeImagePSD @"image/vnd.adobe.photoshop"
FSMimeTypeApplicationAll @"application/*"
FSMimeTypeApplicationPDF @"application/pdf"
FSMimeTypeApplicationDOC @"application/msword"
FSMimeTypeApplicationDOCX @"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
FSMimeTypeApplicationODT @"application/vnd.oasis.opendocument.text"
FSMimeTypeApplicationXLS @"application/vnd.ms-excel"
FSMimeTypeApplicationXLSX @"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
FSMimeTypeApplicationODS @"application/vnd.oasis.opendocument.spreadsheet"
FSMimeTypeApplicationPPT @"application/vnd.ms-powerpoint"
FSMimeTypeApplicationPPTX @"application/vnd.openxmlformats-officedocument.presentationml.presentation"
FSMimeTypeApplicationODP @"application/vnd.oasis.opendocument.presentation"
FSMimeTypeApplicationAI @"application/illustrator"
FSMimeTypeApplicationJSON @"application/json"
FSMimeTypeTextAll @"text/*"
FSMimeTypeTextHTML @"text/html"
FSMimeTypeTextPlain @"text/plain; charset=UTF-8"
(with numbers that they represent in images below)
UIBarStyle navigationBarStyle
NSAttributedString *refreshControlAttributedTitle (11)
UIColor *navigationBarBackgroundColor (6)
UIColor *navigationBarTintColor (1)
UIColor *navigationBarTitleColor
UIColor *headerFooterViewTintColor (2)
UIColor *headerFooterViewTextColor (3)
UIColor *tableViewBackgroundColor
UIColor *tableViewSeparatorColor (5)
UIColor *tableViewCellBackgroundColor (13b)
UIColor *tableViewCellTextColor (13c)
UIColor *cellIconTintColor (4, 17)
UIColor *tableViewCellIconTintColor (4)
UIColor *tableViewCellSelectedBackgroundColor (13)
UIColor *tableViewCellSelectedTextColor (13a)
UIColor *tableViewCellImageViewBorderColor (14)
UIColor *collectionViewBackgroundColor
UIColor *collectionViewCellBackgroundColor
UIColor *collectionViewCellBorderColor (15)
UIColor *collectionViewCellTitleTextColor (16)
UIColor *uploadButtonTextColor (10)
UIColor *uploadButtonBackgroundColor (9)
UIColor *refreshControlTintColor (12)
UIColor *refreshControlBackgroundColor (12a)
UIColor *searchBarBackgroundColor (19)
UIColor *searchBarTintColor (18)
UIColor *activityIndicatorColor
UIColor *progressCircleTrackColor (7)
UIColor *progressCircleProgressColor (8)
// Example
FSTheme *theme = [[FSTheme alloc] init];
theme.uploadButtonTextColor = [UIColor redColor];
theme.progressCircleTrackColor = [UIColor blueColor];
theme.progressCircleProgressColor = [UIColor whiteColor];
NSDictionary *attributes = @{NSForegroundColorAttributeName: [UIColor blackColor]};
theme.refreshControlAttributedTitle = [[NSAttributedString alloc] initWithString:@"Loading stuff" attributes:attributes];
Convenience class to create an optional object that configures how to store the data. FSStoreOptions can be initialized with either NSDictionary
or by default [[FSStoreOptions alloc] init]
and then setting the values "by hand".
// Example
FSStoreOptions *options = [[FSStoreOptions alloc] init];
options.location = FSStoreLocationS3;
// "fileName" and "mimeType" properties are omitted while uploading files using FSPicker.
// Example
FSStoreOptions *options = [[FSStoreOptions alloc] initWithDictionary:@{@"location": FSStoreLocationS3}];
Available dictionary keys (and properties):
FSStoreLocationS3
, FSStoreLocationAzure
, FSStoreLocationDropbox
, FSStoreLocationRackspace
and FSStoreLocationGoogleCloud
). You must have configured your storage in the developer portal to enable this feature.A simple class to store your security policy and signature. FSSecurity instance is a security
parameter in FSStoreOptions.
Read more about security and how to generate policies and signatures
- initWithPolicy:signature:
FSPicker is released under the MIT license. See LICENSE for details.