Files
List Files
List all files that exist in Directus.
Query Parameters
Control what fields are being returned in the object.
A limit on the number of objects that are returned.
How many items to skip when fetching data.
How to sort the returned items. sort
is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-
) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ?
to sort randomly.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
What metadata to return in the response.
GET /files
{
"data": [
{
"id": "8cbb43fe-4cdf-4991-8352-c461779cec02",
"storage": "local",
"filename_disk": "a88c3b72-ac58-5436-a4ec-b2858531333a.jpg",
"filename_download": "avatar.jpg",
"title": "User Avatar",
"type": "image/jpeg",
"folder": null,
"uploaded_by": "63716273-0f29-4648-8a2a-2af2948f6f78",
"created_on": "2019-12-03T00:10:15+00:00",
"charset": "binary",
"filesize": 137862,
"width": 800,
"height": 838,
"duration": 0,
"embed": null,
"tags": [],
"metadata": {},
"uploaded_on": "2019-12-03T00:10:15+00:00"
}
],
"meta": {}
}
POST /files
{
"data": {
"id": "8cbb43fe-4cdf-4991-8352-c461779cec02",
"storage": "local",
"filename_disk": "a88c3b72-ac58-5436-a4ec-b2858531333a.jpg",
"filename_download": "avatar.jpg",
"title": "User Avatar",
"type": "image/jpeg",
"folder": null,
"uploaded_by": "63716273-0f29-4648-8a2a-2af2948f6f78",
"created_on": "2019-12-03T00:10:15+00:00",
"charset": "binary",
"filesize": 137862,
"width": 800,
"height": 838,
"duration": 0,
"embed": null,
"tags": [],
"metadata": {},
"uploaded_on": "2019-12-03T00:10:15+00:00"
}
}
Delete Multiple Files
Delete multiple existing files at once. This will also delete the files from disk.
DELETE /files
Update Multiple Files
Update multiple files at the same time.
Query Parameters
Control what fields are being returned in the object.
A limit on the number of objects that are returned.
What metadata to return in the response.
How many items to skip when fetching data.
How to sort the returned items. sort
is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-
) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ?
to sort randomly.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
Request Body
PATCH /files
{
"data": [
{
"id": "8cbb43fe-4cdf-4991-8352-c461779cec02",
"storage": "local",
"filename_disk": "a88c3b72-ac58-5436-a4ec-b2858531333a.jpg",
"filename_download": "avatar.jpg",
"title": "User Avatar",
"type": "image/jpeg",
"folder": null,
"uploaded_by": "63716273-0f29-4648-8a2a-2af2948f6f78",
"created_on": "2019-12-03T00:10:15+00:00",
"charset": "binary",
"filesize": 137862,
"width": 800,
"height": 838,
"duration": 0,
"embed": null,
"tags": [],
"metadata": {},
"uploaded_on": "2019-12-03T00:10:15+00:00"
}
],
"meta": {}
}
Import a File
Import a file from the web
Request Body
The URL to download the file from.
POST /files/import
{
"data": {
"id": "8cbb43fe-4cdf-4991-8352-c461779cec02",
"storage": "local",
"filename_disk": "a88c3b72-ac58-5436-a4ec-b2858531333a.jpg",
"filename_download": "avatar.jpg",
"title": "User Avatar",
"type": "image/jpeg",
"folder": null,
"uploaded_by": "63716273-0f29-4648-8a2a-2af2948f6f78",
"created_on": "2019-12-03T00:10:15+00:00",
"charset": "binary",
"filesize": 137862,
"width": 800,
"height": 838,
"duration": 0,
"embed": null,
"tags": [],
"metadata": {},
"uploaded_on": "2019-12-03T00:10:15+00:00"
}
}
Retrieve a File
Retrieve a single file by primary key.
Query Parameters
Unique identifier for the object.
Control what fields are being returned in the object.
What metadata to return in the response.
GET /files/{id}
{
"data": {
"id": "8cbb43fe-4cdf-4991-8352-c461779cec02",
"storage": "local",
"filename_disk": "a88c3b72-ac58-5436-a4ec-b2858531333a.jpg",
"filename_download": "avatar.jpg",
"title": "User Avatar",
"type": "image/jpeg",
"folder": null,
"uploaded_by": "63716273-0f29-4648-8a2a-2af2948f6f78",
"created_on": "2019-12-03T00:10:15+00:00",
"charset": "binary",
"filesize": 137862,
"width": 800,
"height": 838,
"duration": 0,
"embed": null,
"tags": [],
"metadata": {},
"uploaded_on": "2019-12-03T00:10:15+00:00"
}
}
Delete a File
Delete an existing file. This will also delete the file from disk.
Query Parameters
Unique identifier for the object.
DELETE /files/{id}
Update a File
Update an existing file, and/or replace it's file contents.
Query Parameters
Unique identifier for the object.
Control what fields are being returned in the object.
What metadata to return in the response.
Request Body
PATCH /files/{id}
{
"data": {
"id": "8cbb43fe-4cdf-4991-8352-c461779cec02",
"storage": "local",
"filename_disk": "a88c3b72-ac58-5436-a4ec-b2858531333a.jpg",
"filename_download": "avatar.jpg",
"title": "User Avatar",
"type": "image/jpeg",
"folder": null,
"uploaded_by": "63716273-0f29-4648-8a2a-2af2948f6f78",
"created_on": "2019-12-03T00:10:15+00:00",
"charset": "binary",
"filesize": 137862,
"width": 800,
"height": 838,
"duration": 0,
"embed": null,
"tags": [],
"metadata": {},
"uploaded_on": "2019-12-03T00:10:15+00:00"
}
}