> ## Documentation Index
> Fetch the complete documentation index at: https://social-b97141fb-feat-user-history-moderation-detail.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# File Posts

> Create file posts with uploaded files using the current social.plus SDKs.

File posts attach uploaded files to a post. Upload files first, then pass the uploaded file objects or file IDs to the post creation API.

<Info>
  This page focuses on the SDK call that creates the post. See [File Handling](/social-plus-sdk/core-concepts/content-handling/files-images-and-videos/file) for upload steps, supported file inputs, and upload constraints.
</Info>

<CardGroup cols={2}>
  <Card title="Uploaded Files" icon="files">
    Create posts from file objects or file IDs returned by the file upload flow.
  </Card>

  <Card title="Caption Support" icon="text">
    Add text, metadata, mentions, or other SDK-supported post fields alongside the file attachments.
  </Card>
</CardGroup>

## Parameters

| Parameter | Required | Platforms | Description |
| - | - | - | - |
| `files`, `uploadedFiles`, or `fileId` | Yes | TypeScript, iOS, Android, Flutter | Uploaded file objects or file IDs, depending on SDK. |
| `text` | No | TypeScript, iOS, Android, Flutter | Caption text shown with the file post. |
| `targetType` | Yes | TypeScript, iOS, Android, Flutter | Feed target, usually `community` or `user`. |
| `targetId` | Yes | TypeScript, iOS, Android, Flutter | Community ID or user ID for the target feed. |
| `metadata` | No | TypeScript, iOS, Android, Flutter | Custom metadata stored with the post where supported. |
| `mentionees` | No | TypeScript, iOS, Android, Flutter | User mention payload where supported by the platform builder. |
| `productTags` | No | TypeScript, iOS | Products named in the parent post text. |
| `attachmentProductTags` | No | TypeScript, iOS | Products shown on child file attachments. An `AmityAttachmentProductTags` container keyed by `fileId`. |

## Create a File Post

The examples below create a file post in a community. Replace the target with the SDK's user-feed target when posting to a user.

<CodeGroup>
  ```swift iOS theme={null}
  func createFilePost(
      uploadedFiles: [AmityFileData],
      communityId: String
  ) async throws -> AmityPost {
      let postRepository = AmityPostRepository()
      let builder = AmityFilePostBuilder()
      builder.setFiles(uploadedFiles)
      builder.setText("Featured product resources")

      let attachmentTags = AmityAttachmentProductTags()
      attachmentTags.set(
          fileId: uploadedFiles[0].fileId,
          tags: [AmityMediaProductTag(productId: "prod_001")]
      )

      return try await postRepository.createFilePost(
          builder,
          targetId: communityId,
          targetType: .community,
          metadata: nil,
          mentionees: nil,
          productTags: [
              AmityTextProductTag(productId: "prod_001", index: 0, length: 12)
          ],
          attachmentProductTags: attachmentTags
      )
  }
  ```

  ```kotlin Android theme={null}
  fun createFilePost(
      uploadedFiles: Set<AmityFile>,
      communityId: String
  ) {
      postRepository.createFilePost(
          targetType = AmityPost.TargetType.COMMUNITY,
          targetId = communityId,
          files = uploadedFiles,
          text = "Resources for the team"
      )
          .subscribe({ post ->
              showSuccessMessage(post.getPostId())
          }, { error ->
              handleGeneralError(error)
          })
  }
  ```

  ```typescript TypeScript theme={null}
  import { AmityAttachmentProductTags, PostRepository } from "@amityco/ts-sdk";

  const attachmentTags = new AmityAttachmentProductTags();
  attachmentTags.set(fileId, [{ productId: "prod_001" }]);

  const { data: post } = await PostRepository.createPost({
    targetType: "community",
    targetId: communityId,
    data: {
      text: "Featured product resources",
    },
    attachments: [
      {
        type: "file",
        fileId,
      },
    ],
    productTags: [
      { productId: "prod_001", text: "Featured product", index: 0, length: 16 },
    ],
    attachmentProductTags: attachmentTags,
  });
  ```

  ```dart Flutter theme={null}
  Future<AmityPost> createFilePost(List<AmityFile> uploadedFiles) {
    return AmitySocialClient.newPostRepository()
        .createPost()
        .targetCommunity(communityId)
        .file(uploadedFiles)
        .text('Resources for the team')
        .post();
  }
  ```
</CodeGroup>

<Note>
  **Product tags (SDK API).** A file post has a text parent and one child per file attachment. TypeScript's generic `createPost` and iOS `createFilePost` expose both text `productTags` for the parent and `attachmentProductTags` for the file children. The public Android and Flutter file creators expose neither field. UIKit's product-tag UI is a separate surface and may support fewer post types; see [UIKit Product Tagging](/uikit/components/social/product-tagging).
</Note>

## Notes

* TypeScript accepts file attachments as `{ type: "file", fileId }`.
* Android accepts a `Set<AmityFile>`.
* iOS accepts `[AmityFileData]`.
* Flutter accepts `List<AmityFile>`.

For mixed attachment types, use [Mixed Media Posts](./mixed-media-post).

## Related Topics

<CardGroup cols={3}>
  <Card title="File Handling" icon="upload" href="/social-plus-sdk/core-concepts/content-handling/files-images-and-videos/file">
    Upload files before creating file posts.
  </Card>

  <Card title="Mixed Media Posts" icon="layer-group" href="./mixed-media-post">
    Combine files with other supported media attachments.
  </Card>

  <Card title="Posts Overview" icon="newspaper" href="../overview">
    Review post concepts, retrieval, and moderation flows.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.