QEDFile

public struct QEDFile : Codable

A QEDFile represents a media file to be notarized by the QEDSDK

  • Describe the type of content for a file

    See more

    Declaration

    Swift

    public enum FileType : Int, Codable
  • Describes the upload status of the file to storage servers

    See more

    Declaration

    Swift

    public enum UploadStatus : Int, Codable
  • Creates a QEDFile instance with the provided name, ext and dateTaken for the local file to represent.

    Note

    The fileURL will be inferred from the file storage directory, the name and the extension(ext).

    Declaration

    Swift

    public init(name: String, extension ext: String, dateTaken: Date)

    Parameters

    name

    A string representing the name of the local file without extension

    ext

    A string representing the extension of the local file

    dateTaken

    A Date instance representing the date the file was created

  • Creates a QEDFile instance from a Dictionary from API response.

    Declaration

    Swift

    public init?(fromQEDAPIResponseDict dict: [String : Any])

    Parameters

    dict

    A dictionary representation of a QEDAPI qualified response with file data

    Return Value

    A new QEDFile instance based on dict. It must include file_name, hash, slug and original_created_at as a minimum otherwise the instantiation will fail and return nil.

  • Default storage directory for the QEDFile represented files in the app’s bundle.

    This directory is used to store the files you want to represent as QEDFile‘s for notarisation.

    You can create QEDFile instances using init(withName:extension:dateTaken:)and the local fileURL location will be assumed to be on the root level of this directory.

    Declaration

    Swift

    public static var qedDirectory: URL { get }
  • The name for the represented file without extension

    Declaration

    Swift

    public var name: String
  • The description for file

    Declaration

    Swift

    public var description: String?
  • ext

    A string representing the type of file (i.e the extension).

    Declaration

    Swift

    public var ext: String
  • The type of content of the file

    Declaration

    Swift

    public var fileType: FileType
  • The client date when the file was created.

    Declaration

    Swift

    public var dateTaken: Date
  • A unique string that identifies the reported file in the backend.

    Note

    When initially created, this value is nil.

    When using the QEDAPI.send(_:in:completion:) method to submit reports, this attribute gets updated based on the response from server.

    Declaration

    Swift

    public var slug: String?
  • An optional arbritary dictionary of additional metadata.

    Declaration

    Swift

    public var metadata: [String : Any]? { get set }
  • Undocumented

    Declaration

    Swift

    public private(set) var metadataStore: [[String] : AnyCodable]?
  • The hash to be stored on the report sent to backend as proof of existence of the associated file.

    It is recommended to use SHA256 to calculate the hash, and the convenience method withCalculatedHash() will take care of this for you.

    Declaration

    Swift

    public var hash: String?
  • Returns a QEDFile instance with the hash calculated from the file at localFileLocation.

    Declaration

    Swift

    public func withCalculatedHash() -> QEDFile

    Return Value

    Returns a copy of the current instance where the SHA256 hash has been calculated from the data in file at localFileLocation. If there is no local file (i.e. localFileLocation == nil) or the hash has been previosuly calculated then the same unaffected instance is returned (i.e. self)

  • The URL where the file is meant to be locally stored.

    There is no guarantee that a file actually exists at this URL. For existance check use localFileLocation

    Declaration

    Swift

    public var fileURL: URL { get }
  • The actual location url for the local file.

    It has the same value as fileURL or nil if the file at fileURL does not exist.

    Declaration

    Swift

    public var localFileLocation: URL? { get }
  • Indicates if the instance references and existing local file at fileURL

    Declaration

    Swift

    public var hasLocalFile: Bool { get }
  • The status of the file upload to storage servers

    Declaration

    Swift

    public var uploadStatus: UploadStatus
  • The remote URL when file is stored on the web

    Declaration

    Swift

    public var remoteUrl: URL?
  • Indicates if the QEDFile can be uploaded.

    Declaration

    Swift

    public var canAttemptFileUpload: Bool { get }

    Return Value

    false If the file does not have a local File to upload. false If the file uploadStatus == uploaded since it is already uploaded. false If the file uploadStatus == external since the file is not meant to be uploaded to storate servers. false If not enough time has passed since the last upload attempt. true otherwise.

  • Use this method to update the date when a file upload has beet attempted for the QEDFile. This is used in conjuction with canAttemptFileUpload to control the file upload attempts rate.

    Declaration

    Swift

    public func updatingFileUploadAttemptDate(_ date: Date) -> QEDFile

    Return Value

    A copy of the QEDFile with and updated last upload attempt date

  • Returns a dictionary representation of the instance.

    The keys are String instances as described on QED REST API. Values are String instances derived from the respective instance attributes.

    Declaration

    Swift

    public func dictionaryRepresentation() -> [String : Any]

    Return Value

    Returns a dictionary compatible with the QEDAPI reporting functionality.

  • Returns a new QEDFile instance by merging the current instance with the provided QEDFile instance.

    Declaration

    Swift

    public func merge(with file: QEDFile) -> QEDFile

    Return Value

    Returns a new QEDFile instance. All the properties of the provided QEDFile instance that are non nil will prevail over the values for the attributes of the current instance.

  • Indicates if the instance content and ids are identical to another

    Declaration

    Swift

    public func isIdentical(to file: QEDFile) -> Bool

    Return Value

    true if id, name, ext, slug, uploadStatus and metadata are identical otherwise false

  • Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.

    < is purely based on the same comparison executed on the dateTaken attribute of the instances.

    Declaration

    Swift

    public static func < (lhs: QEDFile, rhs: QEDFile) -> Bool
  • Returns a Boolean value indicating whether two values are equal.

    Two QEDFile instances are considered equal if they have the same slug (i.e. They represent the same file on the backend).

    If one or both QEDFile‘s are missing the slug, they are considered equal if they have the same id.

    If one or both QEDFile’s are missing the id, they are considered equal if they have the same name and ext.

    Declaration

    Swift

    public static func == (lhs: QEDFile, rhs: QEDFile) -> Bool