File Post
To create a file post, the file must be uploaded first. SDK provides a convenient class AmityFileRepository
to handle uploading and downloading of files. The repository contains uploadFile
method which takes Uri
and provides you with an array of AmityUploadResult
for successful upload or failed uploads. AmityUploadResult
could return four possible types of data.
AmityUploadResult.PROGRESS
indicates an uploading state of the current upload and returnsAmityUploadInfo
to track the progress of the upload.AmityUploadResult.COMPLETE
indicates a successful state of the current upload and returnsAmityFile
to attach.AmityUploadResult.ERROR(exception)
indicates a failure state of the current upload and attachException
.AmityUploadResult.CANCELLED
indicates a canceled state of the current upload.
Now to create the image post. We can build the post first by using AmityFilePostCreator.Builder
. Then use the same createPost
method in AmityFeedRepository
to create an image post.
Note. A post can consist of either a list of images or a list of files but not both.
Create a file post with mention
When creating a file post with mention, you can provide the JsonObject
for the metadata
parameter and provide the list of userId
for the mentionUsers
parameter.
To render mention, refer to Rendering Mention section.
Last updated