File Message

A File message can include any of the following:

  • Image

  • Audio

  • File

  • Custom

Thus, creating an image, audio, file, and custom message have the same steps and sample code. They may only vary slightly on the parameters and metadata.

Image

Amity will automatically optimize the image and when queried, will return the image in small, medium and large sizes. If the image is marked as isFull on upload, the original size of the image can also be returned.

Specifications on image size

When an image is uploaded, it is automatically resized into multiple sizing options. The size of the image is determined by its longest dimension (in pixels) with the aspect ratios being unchanged.

The maximum file size of an image cannot exceed 1 GB.‌

Create the message

To do this, you need to leverage the createFile and pass simply the file ID into the createMessage function.

Here's an example on how to create a message with an attachment. The process is pretty simple:

  1. Upload the file (image, audio, files)

  2. Create a message with the uploaded file ID.

The type parameter can be any of the following:

  • image

  • file

  • audio

  • custom

If you are creating a custom message, you can provide anything inside the data block.

Last updated