QEDFile
public struct QEDFile : Codable
A QEDFile
represents a media file to be notarized by the QEDSDK
-
Creates a
QEDFile
instance with the providedname
,ext
anddateTaken
for the local file to represent.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 dataReturn Value
A new
QEDFile
instance based ondict
. It must include file_name, hash, slug and original_created_at as a minimum otherwise the instantiation will fail and returnnil
.
-
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 usinginit(withName:extension:dateTaken:)
and the localfileURL
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?
-
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 isnil
.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 thehash
calculated from the file atlocalFileLocation
.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 atlocalFileLocation
. 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
Seealso
localFileLocation
Declaration
Swift
public var fileURL: 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 fileuploadStatus == uploaded
since it is already uploaded.false
If the fileuploadStatus == 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 areString
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 providedQEDFile
instance.Declaration
Swift
public func merge(with file: QEDFile) -> QEDFile
Return Value
Returns a new
QEDFile
instance. All the properties of the providedQEDFile
instance that are nonnil
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
ifid
,name
,ext
,slug
,uploadStatus
andmetadata
are identical otherwisefalse
-
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 thedateTaken
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 sameslug
(i.e. They represent the same file on the backend).If one or both
QEDFile
‘s are missing theslug
, they are considered equal if they have the sameid
.If one or both
QEDFile
’s are missing theid
, they are considered equal if they have the samename
andext
.Declaration
Swift
public static func == (lhs: QEDFile, rhs: QEDFile) -> Bool