Get Post
Get Post ID
To access post information or perform actions on a post such as delete and update, you will need the postId
as a parameter. You can retrieve the postId
by doing a feed query which will return a list of the feed's posts along with the post information. Refer to our Feed and Timeline documentation for more details on querying feeds.
Creating a post will also return a response that contains post data with the postId
.
Get Post
You can use the getPost()
method to get a single post. You need to pass the postId
of the requested post as the parameter.
In order to get live update from any changes or bind with StreamBuilder
widget, you can alternatively use AmityPost.listen
The method returns an object
instance of a post model. It will throw an error if an incorrect parameter is passed.
Access Post Information
Each post is represented by AmityPost
instance. Each instance of AmityPost
holds several information such as data, reactions, comments, metadata, child posts, etc. For text posts, you can access the actual data
for the post through data property.
Post with images or files follow Parent - Child relationship. Each image or file uploaded 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
.
You can access data for child post through the same data property for child post. Alternatively, you can also access more details about uploaded files and images by casting them as FileData
, ImageData
, and VideoData.
Let's consider our post contains some text and one image. This means parent post would be a text post and its child post will be an image post. Here is how we can access it.
Getting data from post
To get the URL of an image, file, or video from a post, you can access it inside post.data
method. There are 3 possible types of post data - FileData
, ImageData
, and VideoData.
Every file has a fileUrl
field which can be used to download the file, show the image, or play video.
File Post
To get file URL :
Image Post
Currently, the SDK provides one original quality, and three transcoded quality. The possible qualities are :
to get image URL :
Video Post
Currently, the SDK provides one original quality, and three transcoded quality. The possible qualities are :
to get video URL :
Last updated