Viewing Post Content

Post with images or files follow Parent - Child relationship. Each uploaded image/file will be a separate child post. Any text that you set while creating an image/file post will act as a Parent post. Parent post contains childrenPosts property which gives you an array of AmityPost. Refer to Accessing Post Information for more details.

Viewing Image from post

getImageInfo() returns AmityImageData instance which contains information related to image uploaded for post. [Referring to same sample code above]

AmityImageData contains properties such as:

  • fileId : Id of the file

  • fileUrl : Url of the uploaded file

  • attributes: Dictionary containing additional information about file attributes

  • metadata: Dictionary containing additional information about file metadata

There are two ways to download the uploaded image.

  1. Using AmityFileRepository

    FileRepository class provides dedicated downloadImage(..) method to download images uploaded using same class.

    Note: This class does not perform any kind of caching for downloaded image. Please refer to header docs for download method for more details.

  2. Using any third party library or your own implementation

    You can download the file / image directly from provided fileUrl using your own implementation or any custom third party libraries of your choice.

Image Sizes

For the image uploaded in full size, you can download it in multiple sizes. If you are using AmityFileRepository to download the image, there would be an option to specify size of an image using enum AmityMediaSize.

Use the appropriate image size depending on your use-case to save bandwidth.

  • Small: is used for image thumbnails, with a maximum image size of 160 pixels per dimension. For example, this should be used for small previews in an image gallery that displays a large number of images in a grid.

  • Medium: is used for standard image display, with a maximum image size of 600 pixels per dimension.

  • Large: is used for full-screen image display, with a maximum image size of 1500 pixels per dimension.

  • Full: is used to get the original image. This size is only valid if the image is uploaded with the method isFullImage() set to true. If a FULL sized image is not available, a LARGE sized image will be returned instead.

If you are using your own implementation to download image of appropriate size, you need to construct the download url yourself by appending size query parameter.

For example, to download a small image:

URL provided from AmityImageData: https://my-image-download-link-from-amity/123/456

URL after appending size query parameter: https://my-image-download-link-from-amity/123/456?size=small

Value for Size query parameters can be: small, medium, large, or full.

Viewing file from post

getFileInfo() returns AmityFileData instance which contains information related to file uploaded for post. Refer to Accessing Post Information for more details.

AmityFileData contains properties such as:

  • fileId : Id of the file

  • fileUrl : Url of the uploaded file

  • attributes: Dictionary containing additional information about file attributes

There are two ways to download the uploaded file.

  1. Using AmityFileRepository

    FileRepository class provides dedicated downloadFile(..) method to download files uploaded using same class.

    Note: This class does not perform any kind of caching for downloaded files. Please refer to header docs of download() method for more details.

  2. Using any third party library or your own implementation

    You can download the file directly from provided fileUrl using your own implementation or any custom third party libraries of your choice.

Last updated