You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d973de5
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/files/file-api.md
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,22 @@ Files in epilot are uploaded and managed through the [File API](/api/file).
11
11
12
12
## Downloading Files
13
13
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
+
14
30
The [`downloadFile` operation](/api/file#tag/files/operation/downloadFile) returns a temporary presigned S3 URL for downloading a file.
15
31
16
32
```
@@ -29,10 +45,38 @@ The `download_url` is valid for 15 minutes.
29
45
The `downloadFile` operation requires a valid access token.
30
46
:::
31
47
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
+
32
62
:::note
33
63
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.
34
64
:::
35
65
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
+
36
80
## Uploading Files
37
81
38
82
The [`uploadFileV2` operation](/api/file#tag/files/operation/uploadFileV2) returns a temporary presigned S3 URL for uploading a file via `PUT`.
0 commit comments