PrairieFawkes
PrairieFawkes2w ago

Is there a good way to manage filenaming

Is there a good way to manage filenaming in storage? I have 30 webp that I want to use for banner images for different genres. I want to drop them in the convex front end. Is there any way to name them uniquely or is resourceId the only way to manage or identify a storage item? Do I have to drop them all in one at a time and then write down the id and store that in a config? I don't even think I could drop them all in at once because there's no way to preview the image and see which is which. Am I missing something? Should I be using something else like a third party storage for these?
3 Replies
jamwt
jamwt2w ago
Hi! You need a bit of a filesystem layer on top of raw convex storage. You can do this via a table called files or something. one of the fields in that table would be the storage id, and another one would be the filename. you can rename filenames to another blob in storage by just changing the storage id when the content changes
PrairieFawkes
PrairieFawkesOP2w ago
I created the files table and I spent maybe an hour trying to figure out how to seed a bulk upload from a script but kept running into problems. Had to make an /admin backend with a whole file explorer system just to get the flexibility I wanted. I don't know if this is something that a Convex component could produce, a file system that plugs into a files table, but it would be a nice addition. Maybe even just tags that can be added to storage and indexed. I mean just looking at the storage as it is i can't even figure out what to delete manually because there's no image preview. Supabase is great because I can just navigate to a storage folder for my site assets and dump a whole folder in and then build a string for the file path to reference them. Oh, I just noticed that an image preview shows up when hovering over download button. Dang. I know I have orphaned imaged in there from errors when developing the upload system, but i don't know which ones since all the information is locked away behind an abritrary UUID.
jamwt
jamwt2w ago
if you npx convex export you can get all the files downloaded to see what you have

Did you find this page helpful?