FrankF
Convex Communityโ€ข16mo agoโ€ข
5 replies
Frank

[storage] Is it possible to reference file url instead of storage id in a table?

Hi, I've just started trying out Convex file storage. The documentation uses a chat app example (https://docs.convex.dev/file-storage/serve-files#generating-file-url-in-queries):
1. If the message is an image, it's
message.body
is a storage id
2. when retrieving that message, the convex function uses
await ctx.storage.getUrl(message.body)
to convert storage id to file url

I observed that
1. the storage id is something like
kg25kw...
and the file url is something like
https://<project-id>.convex.cloud/api/storage/ce47fad6-xxxx

2. storage id to file url seems to be a one-to-one mapping

The might be a dumb question but:
- I wonder when creating the message, is it possible to directly store the file url, instead of the storage id?
- In that case I assume when retrieving that message, we can save a network call
ctx.storage.getUrl()


Appreciate any thoughts on this ๐Ÿ™
Files stored in Convex can be served to your users by generating a URL pointing
Serving Files | Convex Developer Hub
Was this page helpful?