kstulgys
kstulgys10mo ago

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
lee
lee10mo ago
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
kstulgys
kstulgysOP10mo ago
thanks, where can I find the example?
lee
lee10mo ago
GitHub
assc/convex/http.ts at master · sshader/assc
Anti Sarah Shader Club. Contribute to sshader/assc development by creating an account on GitHub.
lee
lee10mo ago
but you can also just use convex storage or just hono
lee
lee10mo ago
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.
kstulgys
kstulgysOP10mo ago
can file be saved with specific file name? so it's always url/my-script.js for examnple?
lee
lee10mo ago
yes you can use hono (or more generally an http action) to customize the url
kstulgys
kstulgysOP10mo ago
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?
lee
lee10mo ago
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.
kstulgys
kstulgysOP10mo ago
ah I see. Thank you

Did you find this page helpful?