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.
Relationships
Conforms To
NSObject
Initializers
init(apiKey:security:config:token:)
@objc public init(apiKey: String, security: Security? = nil, config: Config? = nil, token: String? = nil)
Default initializer.
Parameters
Name | Type | Description |
---|---|---|
apiKey | String |
An API key obtained from the Developer Portal. |
security | Security? |
A |
config | Config? |
A |
token | String? |
A token obtained from |
Properties
sdkClient
@objc public let sdkClient: FilestackSDK.Client
The Filestack SDK client used for uploads and transformations.
Methods
upload(from:storeOptions:useIntelligentIngestionIfAvailable:queue:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
localURL | URL |
The URL of the local file to be uploaded. |
storeOptions | StorageOptions |
An object containing the store options (e.g. location, region, container, access, etc. If none given, S3 location with default options is assumed. |
useIntelligentIngestionIfAvailable | Bool |
Attempts to use Intelligent Ingestion for file uploading. Defaults to |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @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.
uploadFromImagePicker(viewController:sourceType:storeOptions:useIntelligentIngestionIfAvailable:queue:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
viewController | UIViewController |
The view controller that will present the picker. |
sourceType | UIImagePickerController.SourceType |
The desired source type (e.g. camera, photo library.) |
storeOptions | StorageOptions |
An object containing the store options (e.g. location, region, container, access, etc.) If none given, S3 location with default options is assumed. |
useIntelligentIngestionIfAvailable | Bool |
Attempts to use Intelligent Ingestion for file uploading. Defaults to |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @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.
uploadFromDocumentPicker(viewController:storeOptions:useIntelligentIngestionIfAvailable:queue:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
viewController | UIViewController |
The view controller that will present the picker. |
storeOptions | StorageOptions |
An object containing the store options (e.g. location, region, container, access, etc.) If none given, S3 location with default options is assumed. |
useIntelligentIngestionIfAvailable | Bool |
Attempts to use Intelligent Ingestion for file uploading. Defaults to |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @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.
uploadFromImagePicker(viewController:sourceType:options:queue:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
viewController | UIViewController |
The view controller that will present the picker. |
sourceType | UIImagePickerController.SourceType |
The desired source type (e.g. camera, photo library.) |
options | UploadOptions |
A set of upload options (see |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @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.
uploadFromDocumentPicker(viewController:options:queue:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
viewController | UIViewController |
The view controller that will present the picker. |
options | UploadOptions |
A set of upload options (see |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @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.
uploadURL(using:options:queue:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
localURL | NSURL |
The URL of the local file to be uploaded. |
options | UploadOptions |
A set of upload options (see |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @escaping (JSONResponse) -> Void |
Adds a handler to be called once the upload has finished. |
Returns
A Uploader
that allows cancelling the upload request.
uploadMultipleURLs(using:options:queue:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
localURLs | [NSURL] |
The URL of the local file to be uploaded. |
options | UploadOptions |
A set of upload options (see |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @escaping ([JSONResponse]) -> Void |
Adds a handler to be called once the upload has finished. |
Returns
A Uploader
that allows cancelling the upload request.
uploadData(using:options:queue:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
data | NSData |
The data to be uploaded. |
options | UploadOptions |
A set of upload options (see |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @escaping (JSONResponse) -> Void |
Adds a handler to be called once the upload has finished. |
Returns
A Uploader
that allows cancelling the upload request.
uploadMultipleData(using:options:queue:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
multipleData | [NSData] |
The array of data objects to be uploaded. |
options | UploadOptions |
A set of upload options (see |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @escaping ([JSONResponse]) -> Void |
Adds a handler to be called once the upload has finished. |
Returns
A Uploader
that allows cancelling the upload request.
picker(storeOptions:)
@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
Name | Type | Description |
---|---|---|
storeOptions | StorageOptions |
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:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
uploadable | FilestackSDK.Uploadable |
An item to upload conforming to |
options | UploadOptions |
A set of upload options (see |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @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:uploadProgress:completionHandler:)
@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
Name | Type | Description |
---|---|---|
uploadables | [FilestackSDK.Uploadable] |
An array of items to upload conforming to |
options | UploadOptions |
A set of upload options (see |
queue | DispatchQueue |
The queue on which the upload progress and completion handlers are dispatched. |
uploadProgress | ((Progress) -> Void)? |
Sets a closure to be called periodically during the lifecycle of the upload process as data is uploaded to the server. |
completionHandler | @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.
pickFiles(using:source:behavior:pickCompletionHandler:uploadCompletionHandler:)
@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
Name | Type | Description |
---|---|---|
presentingViewController | UIViewController |
The view controller that will present the picker. |
source | LocalSource |
The desired local source (e.g. camera, photo library or documents.) |
behavior | PickerBehavior |
The picker behavior (see |
pickCompletionHandler | (([URL]) -> Void)? |
Adds a handler to be called immediately after the files are picked. |
uploadCompletionHandler | (([JSONResponse]) -> Void)? |
Adds a handler to be called once the upload has finished (only called if behavior is set to |
Returns
A Cancellable & Monitorizable
that allows cancelling and monitoring the upload.
folderList(provider:path:pageToken:queue:completionHandler:)
@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
Name | Type | Description |
---|---|---|
provider | CloudProvider |
The cloud provider to use (e.g. Dropbox, GoogleDrive, S3) |
path | String |
The path to list (be sure to include a trailing slash "/".) |
pageToken | String? |
A token obtained from a previous call to this function. This token is included in every |
queue | DispatchQueue |
The queue on which the completion handler is dispatched. |
completionHandler | @escaping FolderListCompletionHandler |
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:storeOptions:queue:completionHandler:)
@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
Name | Type | Description |
---|---|---|
provider | CloudProvider |
The cloud provider to use (e.g. Dropbox, GoogleDrive, S3) |
path | String |
The path to a file in the cloud provider. |
storeOptions | StorageOptions |
An object containing the store options (e.g. location, region, container, access, etc.) If none given, S3 location with default options is assumed. |
queue | DispatchQueue |
The queue on which the completion handler is dispatched. |
completionHandler | @escaping StoreCompletionHandler |
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:completionHandler:)
@objc public func logout(provider: CloudProvider, completionHandler: @escaping LogoutCompletionHandler)
Logs out the user from a given provider.
Parameters
Name | Type | Description |
---|---|---|
provider | CloudProvider |
The |
completionHandler | @escaping LogoutCompletionHandler |
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.) |