#
AttachmentServiceThe AttachmentService
manages the uploads of a message input.
#
Type parametersName | Type |
---|---|
T | extends DefaultStreamChatGenerics = DefaultStreamChatGenerics |
#
Properties#
attachmentUploadInProgressCounter$• attachmentUploadInProgressCounter$: Observable
<number
>
Emits the number of uploads in progress.
#
Defined in#
attachmentUploads$• attachmentUploads$: Observable
<AttachmentUpload
<DefaultStreamChatGenerics
>[]>
Emits the state of the uploads (AttachmentUpload[]
), it adds a state (success
, error
or uploading
) to each file the user selects for upload. It is used by the AttachmentPreviewList
to display the attachment previews.
#
Defined in#
Methods#
addAttachment▸ addAttachment(attachment
): void
You can add custom image
, video
and file
attachments using this method.
Note: If you just want to use your own CDN for file uploads, you don't necessary need this method, you can just specify you own upload function in the ChannelService
#
ParametersName | Type |
---|---|
attachment | Attachment <T > |
#
Returnsvoid
#
Defined in#
createFromAttachments▸ createFromAttachments(attachments
): void
Maps attachments received from the Stream API to uploads. This is useful when editing a message.
#
ParametersName | Type | Description |
---|---|---|
attachments | Attachment <T >[] | Attachemnts received with the message |
#
Returnsvoid
#
Defined in#
deleteAttachment▸ deleteAttachment(upload
): Promise
<void
>
Deletes an attachment, the attachment can have any state (error
, uploading
or success
).
#
ParametersName | Type |
---|---|
upload | AttachmentUpload <DefaultStreamChatGenerics > |
#
ReturnsPromise
<void
>
#
Defined in#
filesSelected▸ filesSelected(fileList
): Promise
<void
>
Uploads the selected files, and creates preview for image files. The result is propagated throught the attachmentUploads$
stream.
#
ParametersName | Type | Description |
---|---|---|
fileList | null | FileList | The files selected by the user |
#
ReturnsPromise
<void
>
A promise with the result
#
Defined in#
mapToAttachments▸ mapToAttachments(): Attachment
<DefaultGenerics
>[]
Maps the current uploads to a format that can be sent along with the message to the Stream API.
#
ReturnsAttachment
<DefaultGenerics
>[]
the attachments
#
Defined in#
resetAttachmentUploads▸ resetAttachmentUploads(): void
Resets the attachments uploads (for example after the message with the attachments sent successfully)
#
Returnsvoid
#
Defined in#
retryAttachmentUpload▸ retryAttachmentUpload(file
): Promise
<void
>
Retries to upload an attachment.
#
ParametersName | Type |
---|---|
file | File |
#
ReturnsPromise
<void
>
A promise with the result