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
  • id

    The unique identifier for the attachment.

    This property returns the appropriate URL based on the current state:

    • For .uploading and .error states: Returns the source URL
    • For .uploaded state: Returns the destination URL

    Declaration

    Swift

    public var id: URL { get }
  • Represents an attachment that is currently being uploaded.

    Declaration

    Swift

    case uploading(sourceURL: URL)

    Parameters

    sourceURL

    The 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

    destinationURL

    The remote URL where the attachment was uploaded

    sourceURL

    The original local URL of the attachment

    extraInfo

    Optional 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

    sourceURL

    The local URL of the attachment that failed to upload

    message

    A description of the error that occurred

  • Determines if two AttachmentInfo instances are equal.

    Declaration

    Swift

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

    Parameters

    lhs

    The left-hand side attachment info to compare

    rhs

    The right-hand side attachment info to compare

    Return Value

    true if the attachment infos are equal, false otherwise

  • Hashes the essential components of this value by feeding them into the given hasher.

    Declaration

    Swift

    public func hash(into hasher: inout Hasher)

    Parameters

    hasher

    The 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 .uploading and .error: Returns the source URL

    Declaration

    Swift

    var primaryURL: URL { get }
  • 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 .error state, nil otherwise