FileStore

open class FileStore<FileType> where FileType : File

Class to interact with the Files collection in the backend.

  • Undocumented

    Declaration

    Swift

    public typealias FileCompletionHandler = (FileType?, Swift.Error?) -> Void
  • Undocumented

    Declaration

    Swift

    public typealias FileDataCompletionHandler = (FileType?, Data?, Swift.Error?) -> Void
  • Undocumented

    Declaration

    Swift

    public typealias FilePathCompletionHandler = (FileType?, URL?, Swift.Error?) -> Void
  • Undocumented

    Declaration

    Swift

    public typealias UIntCompletionHandler = (UInt?, Swift.Error?) -> Void
  • Undocumented

    Declaration

    Swift

    public typealias FileArrayCompletionHandler = ([FileType]?, Swift.Error?) -> Void
  • Constructor that takes a specific Client instance or use the sharedClient instance

    Declaration

    Swift

    public init(client: Client = sharedClient)
  • Uploads a UIImage in a PNG or JPEG format.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.upload(_:image:imageRepresentation:options:completionHandler:﹚ instead")
    @discardableResult
    open func upload(
        _ file: FileType,
        image: NSImage,
        imageRepresentation: ImageRepresentation = .png,
        ttl: TTL? = nil,
        completionHandler: FileCompletionHandler? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a UIImage in a PNG or JPEG format.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.18.0. Please use FileStore.upload(_:image:imageRepresentation:options:completionHandler:﹚ instead")
    @discardableResult
    open func upload(
        _ file: FileType,
        image: NSImage,
        imageRepresentation: ImageRepresentation = .png,
        ttl: TTL? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a UIImage in a PNG or JPEG format.

    Declaration

    Swift

    @discardableResult
    open func upload(
        _ file: FileType,
        image: NSImage,
        imageRepresentation: ImageRepresentation = .png,
        options: Options? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a UIImage in a PNG or JPEG format.

  • Uploads a file using the file path.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.upload(_:path:options:completionHandler:﹚ instead")
    @discardableResult
    open func upload(
        _ file: FileType,
        path: String,
        ttl: TTL? = nil,
        completionHandler: FileCompletionHandler? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a file using the file path.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.upload(_:path:options:completionHandler:﹚ instead")
    @discardableResult
    open func upload(
        _ file: FileType,
        path: String,
        ttl: TTL? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a file using the file path.

    Declaration

    Swift

    @discardableResult
    open func upload(
        _ file: FileType,
        path: String,
        options: Options? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a file using a input stream.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.upload(_:stream:options:completionHandler:﹚ instead")
    @discardableResult
    open func upload(
        _ file: FileType,
        stream: InputStream,
        ttl: TTL? = nil,
        completionHandler: FileCompletionHandler? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a file using a input stream.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.upload(_:stream:options:completionHandler:﹚ instead")
    @discardableResult
    open func upload(
        _ file: FileType,
        stream: InputStream,
        ttl: TTL? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a file using a input stream.

    Declaration

    Swift

    @discardableResult
    open func upload(
        _ file: FileType,
        stream: InputStream,
        options: Options? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a file using a NSData.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.upload(_:data:options:completionHandler:﹚ instead")
    @discardableResult
    open func upload(
        _ file: FileType,
        data: Data,
        ttl: TTL? = nil,
        completionHandler: FileCompletionHandler? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a file using a NSData.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.upload(_:data:options:completionHandler:﹚ instead")
    @discardableResult
    open func upload(
        _ file: FileType,
        data: Data,
        ttl: TTL? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Uploads a file using a NSData.

    Declaration

    Swift

    @discardableResult
    open func upload(
        _ file: FileType,
        data: Data,
        options: Options? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Undocumented

    Declaration

    Swift

    @discardableResult
    open func create(
        _ file: FileType,
        data: Data,
        options: Options? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Undocumented

    Declaration

    Swift

    @discardableResult
    open func create(
        _ file: FileType,
        path: String,
        options: Options? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Undocumented

    Declaration

    Swift

    @discardableResult
    open func create(
        _ file: FileType,
        stream: InputStream,
        options: Options? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Refresh a File instance.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.refresh(_:options:completionHandler:﹚ instead")
    @discardableResult
    open func refresh(
        _ file: FileType,
        ttl: TTL? = nil,
        completionHandler: FileCompletionHandler? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Refresh a File instance.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.refresh(_:options:completionHandler:﹚ instead")
    @discardableResult
    open func refresh(
        _ file: FileType,
        ttl: TTL? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Refresh a File instance.

    Declaration

    Swift

    @discardableResult
    open func refresh(
        _ file: FileType,
        options: Options? = nil,
        completionHandler: ((Swift.Result<FileType, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<FileType, Swift.Error>>
  • Returns the cached file, if exists.

    Declaration

    Swift

    open func cachedFile(_ entityId: String) -> FileType?
  • Returns the cached file, if exists.

    Declaration

    Swift

    open func cachedFile(_ file: FileType) throws -> FileType?
  • Downloads a file using the downloadURL of the File instance.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.download(_:storeType:options:completionHandler:﹚ instead")
    @discardableResult
    open func download(
        _ file: FileType,
        storeType: StoreType = .cache,
        ttl: TTL? = nil,
        completionHandler: FilePathCompletionHandler? = nil
    ) -> AnyRequest<Swift.Result<(FileType, URL), Swift.Error>>
  • Downloads a file using the downloadURL of the File instance.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.download(_:storeType:options:completionHandler:﹚ instead")
    @discardableResult
    open func download(
        _ file: FileType,
        storeType: StoreType = .cache,
        ttl: TTL? = nil,
        completionHandler: ((Swift.Result<(FileType, URL), Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<(FileType, URL), Swift.Error>>
  • Downloads a file using the downloadURL of the File instance.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.21.0. Please use `download(file:storeType:options:completionHandler:﹚` instead")
    @discardableResult
    open func download(
        _ file: FileType,
        storeType: StoreType = .cache,
        options: Options? = nil,
        completionHandler: ((Swift.Result<(FileType, URL), Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<(FileType, URL), Swift.Error>>
  • Downloads a file using the downloadURL of the File instance.

    Declaration

    Swift

    @discardableResult
    open func download(
        file: FileType,
        storeType: StoreType,
        options: Options? = nil,
        completionHandler: ((Swift.Result<(FileType, URL), Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<(FileType, URL), Swift.Error>>
  • Downloads a file using the downloadURL of the File instance.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.download(_:options:completionHandler:﹚ instead")
    @discardableResult
    open func download(
        _ file: FileType,
        ttl: TTL? = nil,
        completionHandler: FileDataCompletionHandler? = nil
    ) -> AnyRequest<Swift.Result<(FileType, Data), Swift.Error>>
  • Downloads a file using the downloadURL of the File instance.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.download(_:options:completionHandler:﹚ instead")
    @discardableResult
    open func download(
        _ file: FileType,
        ttl: TTL? = nil,
        completionHandler: ((Swift.Result<(FileType, Data), Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<(FileType, Data), Swift.Error>>
  • Downloads a file using the downloadURL of the File instance.

    Declaration

    Swift

    @discardableResult
    open func download(
        _ file: FileType,
        options: Options? = nil,
        completionHandler: ((Swift.Result<(FileType, Data), Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<(FileType, Data), Swift.Error>>
  • Deletes a file instance in the backend.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.remove(_:options:completionHandler:﹚ instead")
    @discardableResult
    open func remove(
        _ file: FileType,
        completionHandler: UIntCompletionHandler? = nil
    ) -> AnyRequest<Swift.Result<UInt, Swift.Error>>
  • Deletes a file instance in the backend.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.remove(_:options:completionHandler:﹚ instead")
    @discardableResult
    open func remove(
        _ file: FileType,
        completionHandler: ((Swift.Result<UInt, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<UInt, Swift.Error>>
  • Deletes a file instance in the backend.

    Declaration

    Swift

    @discardableResult
    open func remove(
        _ file: FileType,
        options: Options? = nil,
        completionHandler: ((Swift.Result<UInt, Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<UInt, Swift.Error>>
  • Gets a list of files that matches with the query passed by parameter.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.find(_:options:completionHandler:﹚ instead")
    @discardableResult
    open func find(
        _ query: Query = Query(),
        ttl: TTL? = nil,
        completionHandler: FileArrayCompletionHandler? = nil
    ) -> AnyRequest<Swift.Result<[FileType], Swift.Error>>
  • Gets a list of files that matches with the query passed by parameter.

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated in version 3.17.0. Please use FileStore.find(_:options:completionHandler:﹚ instead")
    @discardableResult
    open func find(
        _ query: Query = Query(),
        ttl: TTL? = nil,
        completionHandler: ((Swift.Result<[FileType], Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<[FileType], Swift.Error>>
  • Gets a list of files that matches with the query passed by parameter.

    Declaration

    Swift

    @discardableResult
    open func find(
        _ query: Query = Query(),
        options: Options? = nil,
        completionHandler: ((Swift.Result<[FileType], Swift.Error>) -> Void)? = nil
    ) -> AnyRequest<Swift.Result<[FileType], Swift.Error>>
  • Clear cached files from local storage.

    Declaration

    Swift

    open func clearCache()