Upload imageId not return after create image post with text

Hello Amity Support,

I am using version 5.4.2 and try to create image post with text using PostRepository.createPost.
the creation is successful but the returned post object have no images records.

here is message log in the websocket channel. Uploading 2 images with text.

the response

we could notice that the returned fileId is not in the list of the request image ids and also return only 1 image instead of 2 images.

and here is the result from SDK object

which there is no expected attachments for files fields to be used

Please provide any solution for this scenario.

Thanks you

@jing

Could you please share the snippet of code from your side for further investigation?

From what I can see from the screenshot, the data field should have text field but somehow yours shows as postText. I did a test from my side and it shows like this

Besides, the statement of “return only 1 image instead of 2 images”, as you can identify from the fileID, the image returned is not the ones you uploaded. That is the community avatar since you created the post into that community.

And if things work correctly, it should return like this, with postChildren inside (each image will be rendered as a child post):

@stevenamity

here is the code

          PostRepository.createPost({
            attachments,
            targetId: communityId,
            targetType: PostTargetType.CommunityFeed,
            dataType: POST_DATA_TYPE, // user.post
            metadata: {
              isMasterPost: false,
              isUserPost: true,
              postText: text,
              link,
              hasUrlPreviewer,
              ...contentData.metadata,
            },
            data: {
              text,
            },
          })

It seems not work by changing key from postTexttext

Hi @jing,

The problem is that you’re using a custom dataType post which is “POST_DATA_TYPE” (user.post) and therefore our backend does not take care of the attachment payload, for that custom posts are entirely up to you to build.

The attachments array would only work for platform’s native posts, for which the payload should be:

PostRepository.createPost({
            targetId: communityId,
            targetType: PostTargetType.CommunityFeed,
            data: { text, },
            attachments,
            metadata: {
              isMasterPost: false,
              isUserPost: true,
              postText: text,
              link,
              hasUrlPreviewer,
              ...contentData.metadata,
            },
          })

Let me know if that helped,

J.

Thank you @Julien

I have tried to remove dataType from body. It hits another error.

here the results

Request

Response
Screen Shot 2564-08-25 at 11.17.30

Please suggest, The goal is creating posts with text and images in the same object.

Thank you.

This issue has been resolved by using the fileId returned from the server instead of the local id