AttachmentInfo
public enum AttachmentInfo : Identifiable, Hashable
Represents the state of an attachment in the attachment flow.
AttachmentInfo tracks the lifecycle of an attachment through three states:
.uploading: The attachment is in the process of being uploaded.uploaded: The attachment has been successfully uploaded.error: An error occurred during the attachment process
-
The unique identifier for the attachment.
This property returns the appropriate URL based on the current state:
- For
.uploadingand.errorstates: Returns the source URL - For
.uploadedstate: Returns the destination URL
Declaration
Swift
public var id: URL { get } - For
-
Represents an attachment that is currently being uploaded.
Declaration
Swift
case uploading(sourceURL: URL)Parameters
sourceURLThe local URL of the attachment being uploaded
-
Represents an attachment that has been successfully uploaded.
Declaration
Swift
case uploaded(destinationURL: URL, sourceURL: URL, extraInfo: (any AttachmentExtraInfo)? = nil)Parameters
destinationURLThe remote URL where the attachment was uploaded
sourceURLThe original local URL of the attachment
extraInfoOptional additional information about the attachment
-
Represents an attachment that encountered an error during the upload process.
Declaration
Swift
case error(sourceURL: URL, message: String)Parameters
sourceURLThe local URL of the attachment that failed to upload
messageA description of the error that occurred
-
Determines if two
AttachmentInfoinstances are equal.Declaration
Swift
public static func == (lhs: AttachmentInfo, rhs: AttachmentInfo) -> BoolParameters
lhsThe left-hand side attachment info to compare
rhsThe right-hand side attachment info to compare
Return Value
trueif the attachment infos are equal,falseotherwise -
Hashes the essential components of this value by feeding them into the given hasher.
Declaration
Swift
public func hash(into hasher: inout Hasher)Parameters
hasherThe hasher to use when combining the components of this instance
-
Returns the primary URL associated with this attachment.
Depending on the state:
- For
.uploaded: Returns the destination URL - For
.uploadingand.error: Returns the source URL
Declaration
Swift
var primaryURL: URL { get } - For
-
Returns the file name of the attachment.
This value is extracted from the last path component of the primary URL.
Declaration
Swift
var attachmentName: String { get } -
Returns the error message if the attachment is in an error state.
Declaration
Swift
var errorMessage: String? { get }Return Value
The error message if in
.errorstate,nilotherwise