> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/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+ 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 | Description                                                   |
| ------------------------------------- | -------- | ------------------------------------------------------------- |
| `files`, `uploadedFiles`, or `fileId` | Yes      | Uploaded file objects or file IDs, depending on SDK.          |
| `text`                                | No       | Caption text shown with the file post.                        |
| `targetType`                          | Yes      | Feed target, usually `community` or `user`.                   |
| `targetId`                            | Yes      | Community ID or user ID for the target feed.                  |
| `metadata`                            | No       | Custom metadata stored with the post where supported.         |
| `mentionees`                          | No       | User mention payload where supported by the platform builder. |

## 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("Resources for the team")

      return try await postRepository.createFilePost(
          builder,
          targetId: communityId,
          targetType: .community,
          metadata: nil,
          mentionees: nil
      )
  }
  ```

  ```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 { PostRepository } from "@amityco/ts-sdk";

  const { data: post } = await PostRepository.createPost({
    targetType: "community",
    targetId: communityId,
    data: {
      text: "Resources for the team",
    },
    attachments: [
      {
        type: "file",
        fileId,
      },
    ],
  });
  ```

  ```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>

## 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>
