> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openpage.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a File Upload

> Create a file upload for a community. Community files can be used as a standard CDN and can be used in any object including Badges, Collections, and more.

<ResponseExample>
  ```json theme={null}
  {
    "name": "testimage1-jpg",
    "key": "fake-uuid-1234-5678-9012-3456/testimage1-jpg",
    "mime": "image/jpeg",
    "url": "https://img.openpage.fun/fake-uuid-1234-5678-9012-3456/testimage1-jpg?format=auto&size=600",
    "communityId": "fake-uuid-1234-5678-9012-3456",
    "thumbnail": null,
    "uploadedAt": null,
    "id": "fake-uuid-1234-5678-9012-3456",
    "createdAt": "2025-03-05T21:27:37.411Z",
    "upload": {
      "method": "POST",
      "url": "https://s3.us-west-2.amazonaws.com/other-page-files",
      "body": {
        "success_action_status": "201",
        "key": "fake-uuid-1234-5678-9012-3456/testimage1-jpg",
        "Content-Type": "image/jpeg",
        "x-amz-meta-account": "fake-uuid-1234-5678-9012-3456",
        "bucket": "other-page-files",
        "X-Amz-Algorithm": "AWS4-HMAC-SHA256",
        "X-Amz-Credential": "ADEFADEFADEF/20250305/us-west-2/s3/aws4_request",
        "X-Amz-Date": "20250305T212737Z",
        "X-Amz-Security-Token": "ALongSecurityStringToken=",
        "Policy": "eyJlExamplePolicyJwt...",
        "X-Amz-Signature": "02342352578923525525253251212745634...",
        "x-amz-meta-file": "fake-uuid-1234-5678-9012-3456",
        "x-amz-meta-community": "fake-uuid-1234-5678-9012-3456"
      }
    }
  }
  ```
</ResponseExample>

## Uploading Your File to The CDN

Once you've created an OpenPage file upload request, you will need to upload the file to make use of it by executing a `POST` request to the file upload endpoint with a body containing the `upload.body` object.

**CURL Request Example**

```bash theme={null}
curl --location 'https://s3.us-west-2.amazonaws.com/other-page-files' \
    --form 'key="fake-uuid-1234-5678-9012-3456/testimage1-jpg"' \
    --form 'success_action_status="201"' \
    --form 'Content-Type="image/jpeg"' \
    --form 'x-amz-meta-account="fake-uuid-1234-5678-9012-3456"' \
    --form 'bucket="other-page-files-dev"' \
    --form 'X-Amz-Algorithm="AWS4-HMAC-SHA256"' \
    --form 'X-Amz-Credential="ADEFADEFADEF/20250305/us-west-2/s3/aws4_request"' \
    --form 'X-Amz-Date="20250305T212737Z"' \
    --form 'Policy="eyJlExamplePolicyJwt..."' \
    --form 'X-Amz-Signature="02342352578923525525253251212745634..."' \
    --form 'x-amz-meta-file="fake-uuid-1234-5678-9012-3456"' \
    --form 'x-amz-meta-community="fake-uuid-1234-5678-9012-3456"' \
    --form 'file=@"/Path/To/Your/File/TestFile.png"'
```

## Image CDN

Image files can make use of the OpenPage image CDN `https://img.openpage.fun/{your-file-key}?format={format}&size={size}` to auto format and resize as needed.

<Info>
  Below is an example of how to return your image with a max size of 100px and as a png.

  `https://img.openpage.fun/fake-uuid-1234-5678-9012-3456/testimage1-jpg?format=png&size=100`
</Info>


## OpenAPI

````yaml POST /community/{id}/file
openapi: 3.0.0
info:
  title: OpenPage API Reference
  description: ''
  version: '1.0'
  contact: {}
servers:
  - url: https://api.openpage.fun/v1
security: []
tags:
  - name: Launcher
    description: >-
      Launcher endpoints are used to interact with your embedded or external
      experiences.


      **Launcher endpoints require setting up a Community Experience.**


      See: [Community
      Experiences](/api-reference/community-experiences/create-experience)
  - name: Communities
    description: >-
      Community endpoints are used to retrieve information about your
      Communities and associated members.


      **Community API endpoints require an API key obtained from the Community
      dashboard.**


      [Community Dashboard](https://portal.openpage.fun)
  - name: Community Badges
    description: >-
      Community Badge endpoints are used to create and manage badges, their
      associated rewards, and member attributions.


      **Community Badge endpoints require an API key obtained from the Community
      dashboard.**


      [Community Dashboard](https://portal.openpage.fun)
  - name: Community Files
    description: >-
      Community File endpoints are used to create and manage files used for
      Badges and Collections.


      **Community File endpoints require an API key obtained from the Community
      dashboard.**


      [Community Dashboard](https://portal.openpage.fun)
  - name: Community Experiences
    description: >-
      Community Experience endpoints are used to create and manage experiences.


      **Community Experience endpoints require an API key obtained from the
      Community dashboard.**


      [Community Dashboard](https://portal.openpage.fun)
paths:
  /community/{id}/file:
    post:
      tags:
        - Community Files
      summary: Create a file upload
      operationId: CommunityFileController_createFile
      parameters:
        - name: id
          required: true
          in: path
          description: Community ID
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFileDto'
      responses:
        '200':
          description: File created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/File'
      security:
        - apiKey: []
components:
  schemas:
    CreateFileDto:
      type: object
      properties:
        name:
          type: string
          description: The name of the file (must include file extension)
      required:
        - name
    File:
      type: object
      properties: {}
  securitySchemes:
    apiKey:
      type: apiKey
      name: X-Api-Key
      in: header

````