Create Post

When creating a post, you can select the target type or which feed you want the post to exist, It can be any of the following:

  • User feed - collection of posts for a user's timeline

  • Community feed - collection of posts from members of the community

  • Content - external content

In creating a post, these are the following parameters:

ParameterDescriptionAttributes

targetId

ID of the user, community, or content. If you want the post to exist in a user feed, you need to provide the userID, etc..

targetType

Where you want the post to exist

UserFeed - post will exist in the user feed

CommunityFeed - post will exist in the community feed

Content - post will exist in the external content

tags

Keywords you want to associate with your post. This is optional. Up to five tags can be added and each tag can be up to 24 characters long

text

Post content (for text post)

IDs

IDs of the media you want to attach to your post

IDs of images, files, videos, and stream

Post target type

The targetType parameter can be any of the following:

  • UserFeed

  • CommunityFeed

  • Content

If you want the post to belong to a user feed, targetType should be UserFeed and targetId is the ID of the user. Otherwise, if you want it to belong to a community, targetType and targetId should be CommunityFeed and the ID of the community respectively.

For an external content post or a post in which the targetType is Content, it can stand on its own without belonging to a user or community. You can create a post object of this type if you want to associate the post to a content (e.g. a news article) in your app which is external to Amity Social Cloud.

Post type

A single post can have up to 20,000 characters. For custom post, the size of the JSON data must not exceed 100KB.

For a successful creation of the post, the reply will be the post model. Otherwise, it will return an error.

Amity SDK supports the creation of the following post types:

File Upload

Before you can create an image, video, file, or custom post, you must first upload the image, video, or the file that you will add to your post. The SDK provides a convenient FileRepository class to handle the uploading of these files.

The model that you will receive from the live object used to upload file via FileRepository will appear in this format:

{
  "fileId": "string",
  "fileUrl": "string",
  "type": "string",	
  "createdAt": "2021-10-04T06:41:26.921Z",
  "updatedAt": "2021-10-04T06:41:26.921Z",
  "attributes": {
      "name": "string",
      "extension": "string",
      "size": "string",
      "mimeType": "string",
      "metadata": {
        "exif": {},
        "gps": {},
        "height": 0,
        "width": 0,
        "isFull": true
      }
    }
}

Model Description

Name

Data Type

Description

Attributes

fileId

String

Root file key on cloud storage

fileUrl

String

Http link for file download

type

enum

File type

image, file, video

createdAt

String($date-time)

The date/time when a file is uploaded

updatedAt

String($date-time)

The date/time when a file is updated

attributes

Object

Information about the file

For more information on the fileObject type, you can refer here.

Last updated