Filestack Documentation

Class Client

@objc(FSFilestackClient) public class Client: NSObject  

The Client class provides an unified API to upload files and manage cloud contents using Filestack REST APIs.

Client Client NSObject NSObject Client->NSObject

Conforms To

NSObject

Initializers

init(api​Key:​security:​config:​token:​)

@objc public init(apiKey: String, security: Security? = nil, config: Config? = nil, token: String? = nil)  

Default initializer.

Parameters

api​Key String

An API key obtained from the Developer Portal.

security Security?

A Security object. nil by default.

config Config?

A Config object. nil by default.

token String?

A token obtained from lastToken to use initially. This could be useful to avoid authenticating against a cloud provider assuming that the passed token has not yet expired.

Properties

api​Key

@objc public let apiKey: String

An API key obtained from the Developer Portal.

security

@objc public let security: Security? 

A Security object. nil by default.

config

@objc public let config: Config

A Config object.

sdk​Client

@objc public let sdkClient: FilestackSDK.Client

The Filestack SDK client used for uploads and transformations.

Methods

upload(from:​store​Options:​use​Intelligent​Ingestion​IfAvailable:​queue:​upload​Progress:​completion​Handler:​)

@objc
    @available(*, deprecated, message: "Marked for removal in version 3.0. Please use upload(using:options:queue:uploadProgress:completionHandler:) instead")
    @discardableResult
    public func upload(from localURL: URL,
                       storeOptions: StorageOptions = .defaults,
                       useIntelligentIngestionIfAvailable: Bool = true,
                       queue: DispatchQueue = .main,
                       uploadProgress: ((Progress) -> Void)? = nil,
                       completionHandler: @escaping (JSONResponse?) -> Void) -> Uploader  

Uploads a file directly to a given storage location (currently only S3 is supported.)

Parameters

local​URL URL

The URL of the local file to be uploaded.

store​Options Storage​Options

An object containing the store options (e.g. location, region, container, access, etc. If none given, S3 location with default options is assumed.

use​Intelligent​Ingestion​IfAvailable Bool

Attempts to use Intelligent Ingestion for file uploading. Defaults to true.

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping (JSONResponse?) -> Void

Adds a handler to be called once the upload has finished.

Returns

An Uploader that allows starting, cancelling and monitoring the upload.

upload​From​Image​Picker(view​Controller:​source​Type:​store​Options:​use​Intelligent​Ingestion​IfAvailable:​queue:​upload​Progress:​completion​Handler:​)

@objc
    @available(*, deprecated, message: "Marked for removal in version 3.0. Please use uploadFromImagePicker(viewController:sourceType:options:queue:uploadProgress:completionHandler:) instead")
    @discardableResult
    public func uploadFromImagePicker(viewController: UIViewController,
                                      sourceType: UIImagePickerController.SourceType,
                                      storeOptions: StorageOptions = .defaults,
                                      useIntelligentIngestionIfAvailable: Bool = true,
                                      queue: DispatchQueue = .main,
                                      uploadProgress: ((Progress) -> Void)? = nil,
                                      completionHandler: @escaping ([JSONResponse]) -> Void) -> Cancellable & Monitorizable  

Uploads a file to a given storage location picked interactively from the camera or the photo library.

Parameters

view​Controller UIView​Controller

The view controller that will present the picker.

source​Type UIImage​Picker​Controller.​Source​Type

The desired source type (e.g. camera, photo library.)

store​Options Storage​Options

An object containing the store options (e.g. location, region, container, access, etc.) If none given, S3 location with default options is assumed.

use​Intelligent​Ingestion​IfAvailable Bool

Attempts to use Intelligent Ingestion for file uploading. Defaults to true.

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping ([JSONResponse]) -> Void

Adds a handler to be called once the upload has finished.

Returns

A Cancellable & Monitorizable that allows cancelling and monitoring the upload.

upload​From​Document​Picker(view​Controller:​store​Options:​use​Intelligent​Ingestion​IfAvailable:​queue:​upload​Progress:​completion​Handler:​)

@objc
    @available(*, deprecated, message: "Marked for removal in version 3.0. Please use uploadFromDocumentPicker(viewController:options:queue:uploadProgress:completionHandler:) instead")
    @discardableResult
    public func uploadFromDocumentPicker(viewController: UIViewController,
                                         storeOptions: StorageOptions = .defaults,
                                         useIntelligentIngestionIfAvailable: Bool = true,
                                         queue: DispatchQueue = .main,
                                         uploadProgress: ((Progress) -> Void)? = nil,
                                         completionHandler: @escaping ([JSONResponse]) -> Void) -> Cancellable & Monitorizable  

Uploads a file to a given storage location picked interactively from the device's documents, iCloud Drive or other third-party cloud services.

Parameters

view​Controller UIView​Controller

The view controller that will present the picker.

store​Options Storage​Options

An object containing the store options (e.g. location, region, container, access, etc.) If none given, S3 location with default options is assumed.

use​Intelligent​Ingestion​IfAvailable Bool

Attempts to use Intelligent Ingestion for file uploading. Defaults to true.

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping ([JSONResponse]) -> Void

Adds a handler to be called once the upload has finished.

Returns

A Cancellable & Monitorizable that allows cancelling and monitoring the upload.

upload​From​Image​Picker(view​Controller:​source​Type:​options:​queue:​upload​Progress:​completion​Handler:​)

@available(*, deprecated, message: "Marked for removal in version 3.0. Use `pickFiles` instead. Additionally, please notice that the `uploadProgress` argument is no longer honored. Instead, you may observe progress on the `Monitorizable` returned by this function.")
    @discardableResult
    public func uploadFromImagePicker(viewController: UIViewController,
                                      sourceType: UIImagePickerController.SourceType,
                                      options: UploadOptions = .defaults,
                                      queue: DispatchQueue = .main,
                                      uploadProgress: ((Progress) -> Void)? = nil,
                                      completionHandler: @escaping ([JSONResponse]) -> Void) -> Cancellable & Monitorizable  

Uploads a file to a given storage location picked interactively from the camera or the photo library.

Parameters

view​Controller UIView​Controller

The view controller that will present the picker.

source​Type UIImage​Picker​Controller.​Source​Type

The desired source type (e.g. camera, photo library.)

options Upload​Options

A set of upload options (see UploadOptions for more information.)

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping ([JSONResponse]) -> Void

Adds a handler to be called once the upload has finished.

Returns

A Cancellable & Monitorizable that allows cancelling and monitoring the upload.

upload​From​Document​Picker(view​Controller:​options:​queue:​upload​Progress:​completion​Handler:​)

@available(*, deprecated, message: "Marked for removal in version 3.0. Use `pickFiles` instead. Additionally, please notice that the `uploadProgress` argument is no longer honored. Instead, you may observe progress on the `Monitorizable` returned by this function.")
    @discardableResult
    public func uploadFromDocumentPicker(viewController: UIViewController,
                                         options: UploadOptions = .defaults,
                                         queue: DispatchQueue = .main,
                                         uploadProgress: ((Progress) -> Void)? = nil,
                                         completionHandler: @escaping ([JSONResponse]) -> Void) -> Cancellable & Monitorizable  

Uploads a file to a given storage location picked interactively from the device's documents, iCloud Drive or other third-party cloud services.

Parameters

view​Controller UIView​Controller

The view controller that will present the picker.

options Upload​Options

A set of upload options (see UploadOptions for more information.)

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping ([JSONResponse]) -> Void

Adds a handler to be called once the upload has finished.

Returns

A Cancellable & Monitorizable that allows cancelling and monitoring the upload.

upload​URL(using:​options:​queue:​upload​Progress:​completion​Handler:​)

@objc
    @discardableResult
    public func uploadURL(using localURL: NSURL,
                          options: UploadOptions = .defaults,
                          queue: DispatchQueue = .main,
                          uploadProgress: ((Progress) -> Void)? = nil,
                          completionHandler: @escaping (JSONResponse) -> Void) -> Uploader  

Uploads a single local URL directly to a given storage location.

Currently the only storage location supported is Amazon S3.

Parameters

local​URL NSURL

The URL of the local file to be uploaded.

options Upload​Options

A set of upload options (see UploadOptions for more information.)

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping (JSONResponse) -> Void

Adds a handler to be called once the upload has finished.

Returns

A Uploader that allows cancelling the upload request.

upload​Multiple​URLs(using:​options:​queue:​upload​Progress:​completion​Handler:​)

@objc
    @discardableResult
    public func uploadMultipleURLs(using localURLs: [NSURL],
                                   options: UploadOptions = .defaults,
                                   queue: DispatchQueue = .main,
                                   uploadProgress: ((Progress) -> Void)? = nil,
                                   completionHandler: @escaping ([JSONResponse]) -> Void) -> Uploader  

Uploads an array of local URLs directly to a given storage location.

Currently the only storage location supported is Amazon S3.

Parameters

local​URLs [NSURL]

The URL of the local file to be uploaded.

options Upload​Options

A set of upload options (see UploadOptions for more information.)

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping ([JSONResponse]) -> Void

Adds a handler to be called once the upload has finished.

Returns

A Uploader that allows cancelling the upload request.

upload​Data(using:​options:​queue:​upload​Progress:​completion​Handler:​)

@objc
    @discardableResult
    public func uploadData(using data: NSData,
                           options: UploadOptions = .defaults,
                           queue: DispatchQueue = .main,
                           uploadProgress: ((Progress) -> Void)? = nil,
                           completionHandler: @escaping (JSONResponse) -> Void) -> Uploader  

Uploads data directly to a given storage location.

Currently the only storage location supported is Amazon S3.

Parameters

data NSData

The data to be uploaded.

options Upload​Options

A set of upload options (see UploadOptions for more information.)

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping (JSONResponse) -> Void

Adds a handler to be called once the upload has finished.

Returns

A Uploader that allows cancelling the upload request.

upload​Multiple​Data(using:​options:​queue:​upload​Progress:​completion​Handler:​)

@objc
    @discardableResult
    public func uploadMultipleData(using multipleData: [NSData],
                                   options: UploadOptions = .defaults,
                                   queue: DispatchQueue = .main,
                                   uploadProgress: ((Progress) -> Void)? = nil,
                                   completionHandler: @escaping ([JSONResponse]) -> Void) -> Uploader  

Uploads multiple data directly to a given storage location.

Currently the only storage location supported is Amazon S3.

Parameters

multiple​Data [NSData]

The array of data objects to be uploaded.

options Upload​Options

A set of upload options (see UploadOptions for more information.)

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping ([JSONResponse]) -> Void

Adds a handler to be called once the upload has finished.

Returns

A Uploader that allows cancelling the upload request.

picker(store​Options:​)

@objc public func picker(storeOptions: StorageOptions = .defaults) -> PickerNavigationController  

Returns an instance of a PickerNavigationController that will allow the user to interactively pick files from a local or cloud source and upload them to a given location.

Parameters

store​Options Storage​Options

An object containing the store options (e.g. location, region, container, access, etc.) If none given, S3 location with default options is assumed.

Returns

A PickerNavigationController that may be presented using present(_:animated:) from your view controller.

upload(using:​options:​queue:​upload​Progress:​completion​Handler:​)

@discardableResult
    public func upload(using uploadable: FilestackSDK.Uploadable,
                       options: UploadOptions = .defaults,
                       queue: DispatchQueue = .main,
                       uploadProgress: ((Progress) -> Void)? = nil,
                       completionHandler: @escaping (JSONResponse) -> Void) -> Uploader  

Uploads a single Uploadable to a given storage location.

Currently the only storage location supported is Amazon S3.

Parameters

uploadable Filestack​SDK.​Uploadable

An item to upload conforming to Uploadable.

options Upload​Options

A set of upload options (see UploadOptions for more information.)

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping (JSONResponse) -> Void

Adds a handler to be called once the upload has finished.

Returns

An Uploader that allows starting, cancelling and monitoring the upload.

upload(using:​options:​queue:​upload​Progress:​completion​Handler:​)

@discardableResult
    public func upload(using uploadables: [FilestackSDK.Uploadable],
                       options: UploadOptions = .defaults,
                       queue: DispatchQueue = .main,
                       uploadProgress: ((Progress) -> Void)? = nil,
                       completionHandler: @escaping ([JSONResponse]) -> Void) -> Uploader & DeferredAdd  

Uploads an array of Uploadable items to a given storage location.

Currently the only storage location supported is Amazon S3.

Parameters

uploadables [Filestack​SDK.​Uploadable]

An array of items to upload conforming to Uploadable. May be nil if you intend to add them later to the returned Uploader.

options Upload​Options

A set of upload options (see UploadOptions for more information.)

queue Dispatch​Queue

The queue on which the upload progress and completion handlers are dispatched.

upload​Progress ((Progress) -> Void)?

Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. nil by default.

completion​Handler @escaping ([JSONResponse]) -> Void

Adds a handler to be called once the upload has finished.

Returns

An Uploader & DeferredAdd that allows starting, cancelling and monitoring the upload, plus adding Uploadables at a later time.

pick​Files(using:​source:​behavior:​pick​Completion​Handler:​upload​Completion​Handler:​)

@discardableResult
    public func pickFiles(using presentingViewController: UIViewController,
                          source: LocalSource,
                          behavior: PickerBehavior,
                          pickCompletionHandler: (([URL]) -> Void)? = nil,
                          uploadCompletionHandler: (([JSONResponse]) -> Void)? = nil) -> Cancellable & Monitorizable  

Allows interactively picking file(s) from a local source (e.g. camera, photo library or documents) and, optionally, uploads the file(s) to Filestack.

Parameters

presenting​View​Controller UIView​Controller

The view controller that will present the picker.

source Local​Source

The desired local source (e.g. camera, photo library or documents.)

behavior Picker​Behavior

The picker behavior (see PickerBehavior for more information.)

pick​Completion​Handler (([URL]) -> Void)?

Adds a handler to be called immediately after the files are picked.

upload​Completion​Handler (([JSONResponse]) -> Void)?

Adds a handler to be called once the upload has finished (only called if behavior is set to .uploadAndStore.)

Returns

A Cancellable & Monitorizable that allows cancelling and monitoring the upload.

folder​List(provider:​path:​page​Token:​queue:​completion​Handler:​)

@objc
    @discardableResult
    public func folderList(provider: CloudProvider,
                           path: String,
                           pageToken: String? = nil,
                           queue: DispatchQueue = .main,
                           completionHandler: @escaping FolderListCompletionHandler) -> Cancellable  

Lists the content of a cloud provider at a given path. Results are paginated (see pageToken below.)

Parameters

provider Cloud​Provider

The cloud provider to use (e.g. Dropbox, GoogleDrive, S3)

path String

The path to list (be sure to include a trailing slash "/".)

page​Token String?

A token obtained from a previous call to this function. This token is included in every FolderListResponse returned by this function in a property called nextToken.

queue Dispatch​Queue

The queue on which the completion handler is dispatched.

completion​Handler @escaping Folder​List​Completion​Handler

Adds a handler to be called once the request has completed either with a success, or error response.

Returns

A Cancellable that allows cancelling the folder list request.

store(provider:​path:​store​Options:​queue:​completion​Handler:​)

@objc
    @discardableResult
    public func store(provider: CloudProvider,
                      path: String,
                      storeOptions: StorageOptions = .defaults,
                      queue: DispatchQueue = .main,
                      completionHandler: @escaping StoreCompletionHandler) -> Cancellable & Monitorizable  

Stores a file from a given cloud provider and path at the desired store location.

Parameters

provider Cloud​Provider

The cloud provider to use (e.g. Dropbox, GoogleDrive, S3)

path String

The path to a file in the cloud provider.

store​Options Storage​Options

An object containing the store options (e.g. location, region, container, access, etc.) If none given, S3 location with default options is assumed.

queue Dispatch​Queue

The queue on which the completion handler is dispatched.

completion​Handler @escaping Store​Completion​Handler

Adds a handler to be called once the request has completed either with a success, or error response.

Returns

A Cancellable that allows cancelling the store request.

logout(provider:​completion​Handler:​)

@objc public func logout(provider: CloudProvider, completionHandler: @escaping LogoutCompletionHandler)  

Logs out the user from a given provider.

Parameters

provider Cloud​Provider

The CloudProvider to logout from.

completion​Handler @escaping Logout​Completion​Handler

Adds a handler to be called once the request has completed. The response will either contain an error (on failure) or nothing at all (on success.)