Hi there, I am building an SSG blog on Astro and would like to serve images locally.
Ideal scenario:
- Upload image to Directus dashboard
- Download images on build
- Serve them as if I was storing them in /src/
Is it hard to do with Directus? Would I need to jump through the hoops or perhaps there is a built-in solution?
Hi @Duckling,
As far as I know, there isn’t a native way in Directus to automatically download and serve uploaded images locally during build. However, it’s definitely possible to achieve what you’re looking for using the Directus Assets API.
You can refer to the official documentation here:
https://directus.io/docs/api/assets#retrieve-an-asset
You’d just need to write a small script that:
- Fetches the uploaded assets from your Directus instance
- Downloads them during build
- Saves them in your
/public/
or /src/
directory so Astro can serve them locally
Hope that helps!