Skip to content

Commit d973de5

Browse files
authored
Merge pull request #138 from epilot-dev/docs/file-download-two-step-flow
docs(files): document two-step download flow and downloadS3File
2 parents d46bf3d + 2ff8159 commit d973de5

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

‎docs/files/file-api.md‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ Files in epilot are uploaded and managed through the [File API](/api/file).
1111

1212
## Downloading Files
1313

14+
Downloading a file is a **two-step process**: the File API returns a temporary download URL, and the file content itself is then fetched from that URL with a second request.
15+
16+
```mermaid
17+
sequenceDiagram
18+
participant Client
19+
participant FileAPI as File API
20+
participant S3 as S3
21+
22+
Client->>FileAPI: GET /v1/files/{id}/download
23+
FileAPI-->>Client: download_url
24+
Client->>S3: GET download_url
25+
S3-->>Client: 200 OK (binary file content)
26+
```
27+
28+
### Step 1: Get a download URL
29+
1430
The [`downloadFile` operation](/api/file#tag/files/operation/downloadFile) returns a temporary presigned S3 URL for downloading a file.
1531

1632
```
@@ -29,10 +45,38 @@ The `download_url` is valid for 15 minutes.
2945
The `downloadFile` operation requires a valid access token.
3046
:::
3147

48+
### Step 2: Fetch the file from the download URL
49+
50+
Make a `GET` request to the returned `download_url` to retrieve the actual file. No `Authorization` header is needed for this request — the URL is presigned.
51+
52+
```
53+
GET {download_url}
54+
```
55+
56+
The response body is the **raw binary file content**, served with the file's original `Content-Type`.
57+
58+
:::note
59+
The download URL always serves binary data, never Base64. If your integration platform (BPMS, iPaaS, low-code tool) shows Base64-encoded content, that is the platform's internal representation of binary response bodies — decode it back to binary before saving the file.
60+
:::
61+
3262
:::note
3363
Public files can also be downloaded directly via their `public_url` property. However, `downloadFile` works for both public and private files and is the recommended approach.
3464
:::
3565

66+
### Downloading by S3 Reference
67+
68+
When you have a file's `s3ref` (bucket and key) but not its entity ID — for example from a webhook payload or an entity attribute value — use the [`downloadS3File` operation](/api/file#tag/File/operation/downloadS3File) instead:
69+
70+
```
71+
POST /v1/files:downloadS3?s3_bucket={bucket}&s3_key={key}
72+
```
73+
74+
It returns the same `download_url` response as `downloadFile`. Fetch the file with a second `GET` request as described above.
75+
76+
:::tip
77+
Pass the `s3_key` value exactly as returned by the API. Object keys store the filename segment percent-encoded (e.g. a file named `Straße 1.pdf` is stored under `.../Stra%C3%9Fe%201.pdf`), so make sure your HTTP client URL-encodes the query parameter value — a literal `%` must arrive encoded as `%25`.
78+
:::
79+
3680
## Uploading Files
3781

3882
The [`uploadFileV2` operation](/api/file#tag/files/operation/uploadFileV2) returns a temporary presigned S3 URL for uploading a file via `PUT`.

0 commit comments

Comments
 (0)