A user asks how to search for attachments in a Discourse forum by their storage name (hash-based filename) rather than the original filename. Another user suggests using Rails console methods like Upload.sha1_from_short_url or Upload.sha1_from_base62_encoded to retrieve the SHA1 hash, which can then be used to find the attachment in the uploads table. The original user confirms the solution works and provides instructions for accessing the Rails console and a SQL query to search for large attachments by size and filename.
Hi, is it possible to search files in storage by their storage names?
I mean to find not by filename, but for its hash-based name which is related to attachment. For example, as an admin I explored forum backup and found some big attachment. I don’t know the original filename to be able quickly pick it in the forum to explore.
I can search by filename, and I see its storage name:
Is any way to friendly operate these attachments? I don’t want delete them from the storage until explore their content (in most cases I would like to clean, trim content and repack them). Probably some method using Data Explorer exists?
the logic of which you can reproduce somewhere else if you need to. With that sha1 hash you can search the uploads table for the value, or use at the console: