Upload & Access Files
This guide will cover importing a file via URL, requesting assets, and using transformation parameters.
Everything you need to start building. Provisioned in 90 seconds.Import a File
In the module bar, click to go to the files module. Click the button and to import a file via URL.
Use https://directus.io/docs/img/examples/files-import.png
and the file will be uploaded to your asset storage.
Access a File
The uploaded file is immediately available via the Data Studio for users with the correct access control. From here, you can download, edit, or replace files.
You can access files via URL in your applications by using the following URL pattern:
https://example.directus.app/assets/<file-id>?access_token=token
The token must belong to a user who has access to read files in the directus_files
collection. If the public role has read access, you can omit the access_token
parameter.
Transform an Image
Directus can transform images via query parameters, commonly used to provide the most suitable size and file format.
Add the following query parameter to the end of your file URL:
width=200
Your new URL should look like this:
https://example.directus.app/assets/<file-id>?access_token=token&width=200
The asset will be transformed, saved to your asset storage, and returned to the user. On subsequent requests, the already transformed asset will be returned.
Next Steps
Read more about uploading files, advanced transformations, and then refer to the Files API reference to manage user accounts.