Skip to content

Commit 4e5e0e5

Browse files
committed
Document file downloads
1 parent 21d9e3b commit 4e5e0e5

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

docs/files/file-api.md

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,50 @@ sidebar_position: 2
1010

1111
Files in epilot are uploaded and managed through the [File API](/api/file).
1212

13+
## Downloading Files
14+
15+
The [`downloadFile` operation](/api/file#tag/files/operation/downloadFile) returns a temporary presigned S3 URL, which the client uses to download a file using the `GET` method.
16+
17+
```
18+
GET https://file.sls.epilot.io/v1/files/4ffdc191-f32c-404a-8520-c403b7408afa/download
19+
```
20+
21+
```json
22+
{
23+
"download_url": "https://epilot-prod-user-content.s3.eu-central-1.amazonaws.com/66/3fe52f11-89d8-4482-a102-b060e9c4b328/Snapshot_202205147_140500.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA5AGXFWQOZC655PER%2F20240307%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20240307T130430Z&X-Amz-Expires=900&X-Amz-Security-Token=IQoJb3JpZ2..."
24+
}
25+
```
26+
27+
The `download_url` in the response is valid for 15 minutes and can be used to download the file using the `GET` method.
28+
29+
:::info
30+
31+
The `downloadFile` operation requires a valid access token to be present in the request.
32+
33+
:::
34+
35+
:::note
36+
37+
The `public_url` property of a file entity may also be used to download a file directly if the file is public. However the `downloadFile` operation works for both public and private files and is the recommended way to download files.
38+
39+
:::
40+
41+
1342
## Uploading Files
1443

15-
The `uploadFile` operation returns a temporary presigned S3 URL, which the client uses to upload a file using the `PUT` or `POST` method.
44+
The [`uploadFile` operation](/api/file#tag/files/operation/uploadFile) returns a temporary presigned S3 URL, which the client uses to upload a file using the `PUT` or `POST` method.
1645

17-
After uploading, the client should call the `saveFile` operation to save the uploaded file as an entity make it permanent.
46+
After uploading, the client should call the [`saveFile` operation](/api/file#tag/files/operation/saveFile) to save the uploaded file as an entity make it permanent.
1847

1948
Files that are uploaded but not saved expire and are deleted within 24 hours.
2049

21-
## Example Flow
50+
:::info
51+
52+
The `uploadFile` operation requires a valid access token to be present in the request. Use the `uploadFilePublic` operation to upload files for Submissions of public journeys.
53+
54+
:::
55+
56+
## Example Upload Flow
2257

2358
### Step 1: Call uploadFile to receive s3ref
2459

@@ -118,8 +153,9 @@ You can now attach the returned file entity to any business entity as a relation
118153

119154
## Updating Files
120155

121-
Modifying or saving new versions of File entities happens via the `saveFile` operation.
156+
Modifying or saving new versions of File entities happens via the [`saveFile` operation](/api/file#tag/files/operation/saveFile).
157+
122158

123159
## Deleting Files
124160

125-
Deleting files is done using the `deleteFile` operation. When the file entity is deleted, the underyling S3 object is deleted permanently.
161+
Deleting files is done using the [`deleteFile` operation](/api/file#tag/files/operation/saveFile). When the file entity is deleted, the underyling S3 object is deleted permanently.

0 commit comments

Comments
 (0)