Client

@objc(FSClient)
public class Client : NSObject

Represents a client that allows communicating with the Filestack REST API.

Lifecycle

  • Default initializer.

    See also

    Security

    Declaration

    Swift

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

    Parameters

    apiKey

    An API key obtained from the Developer Portal.

    security

    A Security object. nil by default.

Objective-C Compatibility

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

    Currently the only storage location supported is Amazon S3.

    Important

    If your uploadable can not return a MIME type (e.g. when passing Data as the uploadable), you must pass a custom UploadOptions with custom storeOptions initialized with a mimeType that better represents your uploadable, otherwise text/plain will be assumed.

    Note

    This function is made available especially for Objective-C SDK users. If you are using Swift, you might want to use upload(using:options:queue:uploadProgress:completionHandler:) instead.

    Declaration

    Swift

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

    Parameters

    localURL

    The URL of the local file to be uploaded.

    options

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

    queue

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

    uploadProgress

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

    completionHandler

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

    Return Value

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

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

    Currently the only storage location supported is Amazon S3.

    Important

    If your uploadable can not return a MIME type (e.g. when passing Data as the uploadable), you must pass a custom UploadOptions with custom storeOptions initialized with a mimeType that better represents your uploadable, otherwise text/plain will be assumed.

    Note

    This function is made available especially for Objective-C SDK users. If you are using Swift, you might want to use upload(using:options:queue:uploadProgress:completionHandler:) instead.

    Declaration

    Swift

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

    Parameters

    localURLs

    The URL of the local file to be uploaded.

    options

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

    queue

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

    uploadProgress

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

    completionHandler

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

    Return Value

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

  • Uploads data directly to a given storage location.

    Currently the only storage location supported is Amazon S3.

    Important

    If your uploadable can not return a MIME type (e.g. when passing Data as the uploadable), you must pass a custom UploadOptions with custom storeOptions initialized with a mimeType that better represents your uploadable, otherwise text/plain will be assumed.

    Note

    This function is made available especially for Objective-C SDK users. If you are using Swift, you might want to use upload(using:options:queue:uploadProgress:completionHandler:) instead.

    Declaration

    Swift

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

    Parameters

    data

    The data to be uploaded.

    options

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

    queue

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

    uploadProgress

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

    completionHandler

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

    Return Value

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

  • Uploads multiple data directly to a given storage location.

    Currently the only storage location supported is Amazon S3.

    Important

    If your uploadable can not return a MIME type (e.g. when passing Data as the uploadable), you must pass a custom UploadOptions with custom storeOptions initialized with a mimeType that better represents your uploadable, otherwise text/plain will be assumed.

    Note

    This function is made available especially for Objective-C SDK users. If you are using Swift, you might want to use add(uploadables:) instead.

    Declaration

    Swift

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

    Parameters

    multipleData

    The array of data objects to be uploaded.

    options

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

    queue

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

    uploadProgress

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

    completionHandler

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

    Return Value

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

Public Computed Properties

  • An API key obtained from the Developer Portal.

    Declaration

    Swift

    @objc
    var apiKey: String { get }
  • A Security object. nil by default.

    Declaration

    Swift

    @objc
    var security: Security? { get }
  • Returns an array containing the Uploader instances currently running.

    Declaration

    Swift

    @objc
    var currentUploaders: [Uploader] { get }
  • Returns whether there’s at least a single Uploader instance currently running.

    Declaration

    Swift

    @objc
    var isUploading: Bool { get }

Public Functions

  • A FileLink object for a given Filestack handle.

    Declaration

    Swift

    @objc
    func fileLink(for handle: String) -> FileLink

    Parameters

    handle

    A Filestack handle.

  • A Transformable object for a Filestack handle.

    See also

    Transformable

    Declaration

    Swift

    @objc
    func transformable(handle: String) -> Transformable

    Parameters

    handle

    A Filestack handle.

  • A Transformable object for an array of Filestack handles.

    See also

    Transformable

    Declaration

    Swift

    @objc
    func transformable(handles: [String]) -> Transformable

    Parameters

    handles

    An array of Filestack handles.

  • A Transformable object for an external URL.

    See also

    Transformable

    Declaration

    Swift

    @objc
    func transformable(externalURL: URL) -> Transformable

    Parameters

    externalURL

    An external URL.

  • A Transformable object for an array of external URLs.

    See also

    Transformable

    Declaration

    Swift

    @objc
    func transformable(externalURLs: [URL]) -> Transformable

    Parameters

    externalURLs

    An array of external URLs.

  • Uploads a single Uploadable to a given storage location.

    Currently the only storage location supported is Amazon S3.

    Important

    If your uploadable can not return a MIME type (e.g. when passing Data as the uploadable), you must pass a custom UploadOptions with custom storeOptions initialized with a mimeType that better represents your uploadable, otherwise text/plain will be assumed.

    Declaration

    Swift

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

    Parameters

    uploadable

    An item to upload conforming to Uploadable.

    options

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

    queue

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

    uploadProgress

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

    completionHandler

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

    Return Value

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

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

    Currently the only storage location supported is Amazon S3.

    Important

    If your uploadables can not return a MIME type (e.g. when passing Data as the uploadable), you must pass a custom UploadOptions with custom storeOptions initialized with a mimeType that better represents your uploadables, otherwise text/plain will be assumed.

    Declaration

    Swift

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

    Parameters

    uploadables

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

    options

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

    queue

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

    uploadProgress

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

    completionHandler

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

    Return Value

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