Attachment

@Immutable
data class Attachment(val authorName: String? = null, val authorLink: String? = null, val titleLink: String? = null, val thumbUrl: String? = null, val imageUrl: String? = null, val assetUrl: String? = null, val ogUrl: String? = null, val mimeType: String? = null, val fileSize: Int = 0, val title: String? = null, val text: String? = null, val type: String? = null, val image: String? = null, val name: String? = null, val fallback: String? = null, val originalHeight: Int? = null, val originalWidth: Int? = null, val upload: File? = null, val uploadState: Attachment.UploadState? = null, val extraData: Map<String, Any> = mapOf()) : CustomObject

Represents an attachment. Most commonly these are files, images, videos and audio recordings, but the class is flexible enough that it can represent other things as well such as a date, a given location or other things.

If you want to create a custom attachment we suggest you use extraData to store the information you need.

Parameters

authorName

The name of the site the URL leads to.

authorLink

The link to the website.

titleLink

The link to the URL or the resource linked.

thumbUrl

The URL for the thumbnail version of the attachment, given the attachment has a visual quality, e.g. is a video, an image, a link to a website or similar.

imageUrl

The URL for the raw version of the attachment.

assetUrl

The URL for the asset.

ogUrl

The original link that was enriched.

mimeType

The mime type of the given attachment. e.g. "image/jpeg"

fileSize

The size of the given attachment.

title

The title of the attachment.

text

The page description.

type

The type of the attachment. e.g "file", "image, "audio".

image

The image attachment.

fallback

Alternative description in the case of an image attachment (img alt in HTML).

originalHeight

The original height of the attachment. Provided if the attachment is of type "image".

originalWidth

The original width of the attachment. Provided if the attachment is of type "image".

upload

The local file that will be uploaded when the attachment is sent.

uploadState

The state of the upload, i.e. the current progress of uploading the file.

extraData

Stores various extra information that can be sent when uploading the attachment or read when downloading it.

Constructors

Link copied to clipboard
constructor(authorName: String? = null, authorLink: String? = null, titleLink: String? = null, thumbUrl: String? = null, imageUrl: String? = null, assetUrl: String? = null, ogUrl: String? = null, mimeType: String? = null, fileSize: Int = 0, title: String? = null, text: String? = null, type: String? = null, image: String? = null, name: String? = null, fallback: String? = null, originalHeight: Int? = null, originalWidth: Int? = null, upload: File? = null, uploadState: Attachment.UploadState? = null, extraData: Map<String, Any> = mapOf())

Types

Link copied to clipboard
class Builder
Link copied to clipboard
sealed class UploadState

Represents various states in attachment upload lifecycle.

Properties

Link copied to clipboard
val assetUrl: String? = null
Link copied to clipboard
val authorLink: String? = null
Link copied to clipboard
val authorName: String? = null
Link copied to clipboard
open override val extraData: Map<String, Any>
Link copied to clipboard
val fallback: String? = null
Link copied to clipboard
val fileSize: Int = 0
Link copied to clipboard
val image: String? = null
Link copied to clipboard
val imageUrl: String? = null
Link copied to clipboard
val mimeType: String? = null
Link copied to clipboard
val name: String? = null
Link copied to clipboard
val ogUrl: String? = null
Link copied to clipboard
val originalHeight: Int? = null
Link copied to clipboard
val originalWidth: Int? = null
Link copied to clipboard
val text: String? = null
Link copied to clipboard
val thumbUrl: String? = null
Link copied to clipboard
val title: String? = null
Link copied to clipboard
val titleLink: String? = null
Link copied to clipboard
val type: String? = null
Link copied to clipboard
val upload: File? = null

The local file to upload when the attachment is sent. The assetUrl property will be populated with the URL of the uploaded file when done.

Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
open override fun toString(): String

Inherited functions

Link copied to clipboard
open fun <T> getExtraValue(key: String, default: T): T