Another idea, which may require too much effort on the part of the user, is to show a unique token or url for each uploaded piece of content. The user can choose to store this and use it to edit the content.
Advantages: it's more anonymous, since there are no cookies to track users, and you can't even track which pieces of content are uploaded by the same user. The tokens also persist after clearing cookies or even reinstalling the PC.
Disadvantages: it's clearly quite some effort for the user to keep track of all the tokens.
P.s. it sounds like may use your service to upload nsfw or copyrighted content.... But maybe that's the point.
Hashnode is a friendly and inclusive dev community.
Come jump on the bandwagon!
💬 Ask programming questions without being judged
🧠 Stay in the loop and grow your knowledge
🍕 More than 500K developers share programming wisdom here
❤️ Support the growing dev community!
Even though they're anonymous users, generate a unique id for each user from the client side itself and save it in cookies with a long expiry.
Whenever someone uploads a file save that unique id along with the file. Now you can allow users to edit the file if its owner is the same as in the cookies.
You can use uuidv4 or something for unique ids
I'd at least make them type in an e-mail address if they want to edit. Generate an authorization code for editing, and send it to them that way. OR just display the edit authorization code when they create the file, they lose that code, well... that's their fault.
Any other method -- sessions, cookies, localstorage -- isn't portable or permanent.
No need to collect anything from users instead, hash the things as discussed here. Let users upload the content no strings attached, now generate a very long id lets say its the private key to the user, now make sure you have your very own secret key with you that you will be using for all the requests. Now to store the file, ask them to give some name/generate something random yourself, using your secret key and the users private key, create a permanent hash and append it with the file name and store it.
Lets say, User's private key = DDA22E18DA54C1494E90324ADE71400C48DEC72AEE5C25B2A0A63CD497398052 ( this is SHA256 of "hashnode") Your private key = 2F183A4E64493AF3F377F745EDA502363CD3E7EF6E4D266D444758DE0A85FCC8 (SHA256 of "anonymous")
Now to store the file : SHA256(SHA256(user's private key) + SHA256(your private key)) 7433BACE002F1403E6AFCFF8A5FE8FBAE55192682992802E160C2A388E0FA1F4 + 2C9A303023DEF128C4FBC1FBF1C70BE6A1F9739A3D765DFC4F24DA9AD6D725A7
The final hash : E954EA3B3AE1B245C2B6C664D88582887ED986613F6CD18A5E1166AD9BFFBF85
Now create a directory with the final hash and store the files inside that directory with some random name/number/name given by user into that folder.
To retrieve the files. Just take in the user's private key SHA256 it, SHA256 your secret key and then SHA256 the whole appended hash, you have the directory name. Lookup the directory, if its present list the files else the user has no files yet. If looking up files/ reading a huge directory is not a good idea. Instead, you can use a database to verify if files are present or not.
You can modify this to give particular links to every file as per other discussions done here.
To make it user-friendly store the user's private key in local storage and then retrieve it next time automatically when the page loads.
Disadvantage: If the user loses his so-called private key, everything is gone.