> For the complete documentation index, see [llms.txt](https://docs.tnid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tnid.com/api-reference/001_user/012_documents/001__prepare_file_upload_as_user.md).

# Prepare File Upload (User)

GraphQL endpoint: `/user`

Prepares a file upload for the calling user. Returns a presigned upload URL to PUT the file to and the file key to save; the key is randomized per request.

## Query

```graphql
mutation (
  $fileName: String!
  $contentType: String!
) {
  prepareFileUpload(
    fileName: $fileName
    contentType: $contentType
  ) {
    uploadUrl
    fileKey
  }
}

```

## Variables

```json
{
  "contentType": "image/jpeg",
  "fileName": "avatar.jpg"
}
```

## Response

```json
{
  "data": {
    "prepareFileUpload": {
      "fileKey": "user_uploads/2026-01-15_examplekey1_avatar.jpg",
      "uploadUrl": "http://localhost:4566/tnid-v2-uploads-local/user_uploads/2026-01-15_examplekey1_avatar.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=SOME_RANDOM_ACCESS_KEY%2F20260115%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260115T090000Z&X-Amz-Expires=900&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Signature=0000000000000000000000000000000000000000000000000000000000000000"
    }
  }
}
```
