Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions content/guides/05.files/1.upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Optionally, you can also click the file display to open the file details page an
## API

::code-group

```http [REST]
// POST /files

Expand All @@ -37,15 +38,16 @@ Body must be formatted as a `multipart/form-data` with a final property called `
```

```js [SDK]
import { createDirectus, rest, uploadFiles } from '@directus/sdk';
import { createDirectus, rest, uploadFiles } from "@directus/sdk";

const directus = createDirectus('https://directus.example.com').with(rest());
const directus = createDirectus("https://directus.example.com").with(rest());

const formData = new FormData();
formData.append('file_1_property', 'Value');
formData.append('file', raw_file);
formData.append('file_2_property', 'Value');
formData.append('file', raw_file_2);
formData.append("storage", "s3"); // optional, defaults to first STORAGE_LOCATIONS
formData.append("file_1_property", "Value");
formData.append("file", raw_file);
formData.append("file_2_property", "Value");
formData.append("file", raw_file_2);

const result = await directus.request(uploadFiles(formData));
```
Expand All @@ -54,3 +56,6 @@ const result = await directus.request(uploadFiles(formData));

The file contents has to be provided in a property called `file`. All other properties of
the file object can be provided as well, except `filename_disk` and `filename_download`.

You can optionally provide a `storage` property to specify which storage location to use. If omitted, it defaults to
the first location configured in the `STORAGE_LOCATIONS` environment variable.