KV Assets (site bucket) __STATIC_CONTENT is are suffixed with hashes (05c5fa8db8)
Hi all,
We're trying to use a workers sites bucket defined in our API wrangler to host some (temporary) image assets in to show in our app, but once we attempt to fetch these we see that they are suffixed with hashes. What is the recommended way to continue here so we can access assets in these buckets through e.g.
/public/some-temp-image.png
? We use getAssetFromKV:
Can we skip workers sites from adding these hashes?4 Replies
What exactly do you mean by suffixed with hashes? Yes, behind the scenes in KV they are stored as
some-temp-image.[hash].png
for example, but you can serve that image at some-temp-image.png
without the hash just fine. That's pretty much exactly the point of what kv-asset-handler
does 🤔 Is there something I'm missing or you can clarify?@cherryjimbo thanks for your quick response, I've actually managed to find it by just reading the docs of getAssetFromKV a bit better. I forgot to add ASSET_MANIFEST as a property to getAssetFromKV, and import it like this:
import manifestJSON from "__STATIC_CONTENT_MANIFEST";
For the typescript people, I also added the following declaration file:
Ah perfect, glad you've figured it out 🙂
Thanks! This behavior isn't in the local wrangler server, have a list of a couple of other small points that differ between cloudflare / wrangler / miniflare / workerd, I will add some issues for these soon on Github so it'll be easier for the next person 😉