I need to generate unique folder name to be created in an object storage. I don't care what the name will be, i just need to Ensure that it will be unique. I am using a python script with boto3 to create the folders and I need to run the script many different times. what is the best way to do that?
Asked
Active
Viewed 51 times
0
-
Any tries of yours already? We won't be able to help without some code of yours. – harmonica141 Dec 25 '19 at 15:17
-
One way would be to use uuid, if that doesn't violate any other restraints – Fábio Dias Dec 25 '19 at 15:20
-
maybe just a random string? https://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits – Nicolas Gervais Dec 25 '19 at 15:22
1 Answers
1
The key part is not how you generate the name. It is that you attempt to create the name and handle the failure if it already exists. Do not check for existence. If the creation succeeds then you have a unique name and that name is not in use by any concurrent process.

Dan D.
- 73,243
- 15
- 104
- 123