I have a web application where users can upload office documents. In addition to uploading files users also specify extra information about them that's not contained in the files themselves but is important to the web application. Information such as mydocument.docx is a brochure or a manual, etc.
The files are uploaded immediately upon selection but the other information such as whether or not a particular file is a brochure is only sent to the server later when the user clicks a save button.
So I need a way to sync the information a user submits about a file with the file data even though they're uploaded separately. I first thought of using an MD5 hash of each file's data as a way to link the information, but the performance is terrible and makes it unfeasible.
Another idea I have is to use Math.random plus the filename and the user's ID as a key to connect them. Since Math.random is seeded based on system time it should be unique enough that collisions would be highly unlikely.
Is there a better way to do this that I'm missing? Both of these methods feel a little heavy handed/hacky for what I'm trying to do.