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

# File

> Upload files via checksums and presigned upload URLs before attaching them to invoices.

## Flow of uploading files

For uploading files you send a list of files to upload:

```json theme={null}
{
  "files": [
    {
      "byte_size":    "12345",
      "checksum":     "JVBERi0xLjQKJeLjz9MKMSAwIG9iajw8L0NvbnETCETERA...",
      "content_type": "application/pdf"
    }
  ],
  "administration_id": "1"
}
```

Payt will return a list of files that need uploading. **Files that are already present are not returned.**

```json theme={null}
[
  {
    "checksum":     "JVBERi0xLjQKJeLjz9MKMSAwIG9iajw8L0NvbnETCETERA...",
    "expires_at":   "timestamp_4_hours_from_now",
    "url":          "https://url_to_upload_file.paytsoftware.com"
  }
]
```

After that, you can upload the file to the presented URL. There the file will be checked if it matches on byte\_size, content\_type and checksum.

```shell theme={null}
curl --request PUT \
  --url http://localhost:3000/file_storage/disk/eyJfcmFpbHMiOnsiZGF0YSI6eyJjaGVja3N1bSI6IkRyL0xQVTdUUVZLNHB3Lzh3WEs4cEV2VzBjL3BDSkh0Qi9CYldLMENzZmIydkJQN21EQjFZajBSTjg2STNvcUZBT0tlOGJTdGsxcTJ5b0poYlpJRjBRPT0iLCJjb250ZW50X3R5cGUiOiJhcHBsaWNhdGlvbi9wZGYiLCJjb250ZW50X2xlbmd0aCI6NDM2MTZ9LCJleHAiOiIyMDI0LTA5LTE3VDEyOjA0OjI4LjU2MloiLCJwdXIiOiJibG9iX3Rva2VuIn19--75d0d86602ca4f7dbe7126d4c46c6c8fce898b69 \
  --header 'Content-Type: application/pdf' \
  --data 'JVBERi0xLjQKJeLjz9MKMSAwIG9iaiAKPDwKL00gKEQ6MjAxMjAzMjcxMD...='
```

## Checking file integrity

Payt uses checksum values to verify the integrity of data that you upload. Payt uses the Secure Hash Algorithm 3 with 512 bits ([SHA3-512](https://en.wikipedia.org/wiki/SHA-3)). This is encoded with [Base64](https://en.wikipedia.org/wiki/Base64) encoding. This results in a string with 88 characters, the length of this checksum will be validated.

## Fields

| Field name        | Description                                                                                                   |
| ----------------- | ------------------------------------------------------------------------------------------------------------- |
| **checksum**      | Checksum of file with SHA3-512 hashing and Base64 encoding                                                    |
| **byte\_size**    | Size of file in bytes                                                                                         |
| **content\_type** | [Mime type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) of file |
