# Adding more images into an existing media post

**URL:** <https://forum.social.plus/t/adding-more-images-into-an-existing-media-post/1433>\
**Category:** TS SDK\
**Created:** [August 21, 2024, 10:39am UTC](https://forum.social.plus/t/adding-more-images-into-an-existing-media-post/1433 "2024-08-21T10:39:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aamir.shehzad](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@aamir.shehzad](https://forum.social.plus/u/aamir.shehzad)\
**Post date:** [August 21, 2024, 10:39am UTC](https://forum.social.plus/t/adding-more-images-into-an-existing-media-post/1433/1 "2024-08-21T10:39:50Z")

</div>

Hi,

Hope you’re doing well.

I have a post that contains text content and an image into it. Now, I have to implement the **Edit Post Feature** in which I wanna change the text content and add more images into it. The update of text change is working with `PostRepository.editPost();` API but adding more images into it is not working.  
How to implement this change?

Best,  
Aamir Shehzad

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [August 21, 2024, 10:54am UTC](https://forum.social.plus/t/adding-more-images-into-an-existing-media-post/1433/2 "2024-08-21T10:54:25Z")

</div>

Hello @aamir.shehzad , We need additional information from you to investigate this issue:

1. The platform and version you are using.
2. The full code related to the issue you are encountering.

This will help us better understand the problem and provide a more accurate solution. Thank you

---

<div class="post-metadata">

**Author:** ![mustafa](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mustafa](https://forum.social.plus/u/mustafa)\
**Post date:** [August 22, 2024, 6:28am UTC](https://forum.social.plus/t/adding-more-images-into-an-existing-media-post/1433/3 "2024-08-22T06:28:25Z")

</div>

Hi @SocialPlus_Support,

I’m using React Native for both iOS and Android with TypeScript. For adding media, I’m using metadata when creating the post. The first time, if I create only post including images, it works fine. Then I’m implementing edit post feature, and the images are not being attached to the exiting post.  
Let me show you my code:

```auto
  const handleEditPost = async () => {
    try {
      const updatedPost = {
        data: {
          text: text,
        }
      };

      if (imageUri.length > 0) {
        const uploadPromises = imageUri.map(async (element) => {
          console.log("image ==== >", element);
          const { uri } = element;

          console.log("uri ==== >", uri);
          const data = new FormData();
          data.append('files', { uri, name: 'post_image', type: 'image/jpeg' });
          const { data: image } = await FileRepository.uploadImage(data);
          return image[0];
        });

        await Promise.all(uploadPromises)
          .then((imageArray) => {
            console.log('All images uploaded successfully:', imageArray);
            updatedPost.metadata = {
              image: {
                data: imageArray
              },
            };
            return;
          })
          .catch((error) => {
            console.error('Error uploading images:', error.message);
          });
      }

      const { data: post } = await PostRepository.editPost(postId, updatedPost);
      console.log(`Edit Success! Updated post ${JSON.stringify(post)}`);

    } catch (error) {
      console.log("Faild to edit post due to ", error);
    } finally {
      onClose();
      setIsLoading(false);
    }
  };

```

I’m happy to share more information if required.

Best,

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [August 22, 2024, 7:07am UTC](https://forum.social.plus/t/adding-more-images-into-an-existing-media-post/1433/4 "2024-08-22T07:07:45Z")

</div>

Hello @mustafa , Based on our team’s review, we recommend referring to this documentation for implementation: [Edit a Post](https://docs.amity.co/amity-sdk/social/posts/edit-post). Specifically, use attachments instead of metadata for adding images to the post.

Please let us know if you need further assistance.
