Can I use convex file storage to upload a javascript file?
I want to upload/update my javascript file then use it like:
<script src="https://my-convex-storage/my-script.js"/>
is that possible? is that normal lol?
10 Replies
yes this should work. we have an example or two that serves static html/css from convex file storage, so javascript should be no problem
thanks, where can I find the example?
GitHub
assc/convex/http.ts at master · sshader/assc
Anti Sarah Shader Club. Contribute to sshader/assc development by creating an account on GitHub.
but you can also just use convex storage or just hono
Advanced HTTP Endpoints: Convex ❤️ Hono
Adding advanced HTTP Endpoint functionality by extending Convex with Hono.
File Storage | Convex Developer Hub
Store and serve files of any type.
can file be saved with specific file name? so it's always url/my-script.js for examnple?
yes you can use hono (or more generally an http action) to customize the url
I don't think I understand. Whats so special about hono?
how do I customize the url?
I mean when I use storage id I fetch url. That ur is random, no?
hono is just a nice interface for http actions.
see this example: https://github.com/sshader/assc/blob/master/convex/http.ts#L27 where we take the path from the url, like
/my-script.js
, convert it to a path, look up path -> storage id with a query, and return the stored file from convex storage.GitHub
assc/convex/http.ts at master · sshader/assc
Anti Sarah Shader Club. Contribute to sshader/assc development by creating an account on GitHub.
ah I see. Thank you