Etag and Content-Type support in KV Storage

Is there a way to store metadata for an item in KV Storage when posting? Specifically it would be great if you could store the content-type of the object and a ETag, so that we can serve 304’s easily.

I guess we could prepend the tags in the beginning of the files or solve it some other creative way, but would prefer not to if possible.

Thanks!

1 Like

Afaik, the only way to store “metadata” is to add it to the KV key name and then use the prefix to retrieve them.

See:

Be aware of the higher costs to listing:

So to use this with storage, you’d have to roll your own File upload mechanism using the API, located here:

https://api.cloudflare.com/#workers-kv-namespace-write-key-value-pair

1 Like

We should have a good solution for you here sometime in the near future!

5 Likes

That sounds promising! Do you have a rough timeline on when you think it will be available? Would be great if we could wait for the proper solution instead of implementing a hack around it.

1 Like

Thanks @thomas4! That’s a nicer solution than what I came up with :slight_smile:

1 Like

I can’t make promises, but it’s more like “a month or so” than “six months or so”.