Uploaded files renaming - using uuid instead of the file->hashName()
Hello,
I noticed that Laravel's hashName() uses the random string method with length of 40.
But would that be better to use uuid instead?
i.e.:
// in controller
$file => $request->file;
$uuid = Str::uuid();
$extension = $file->extension();
$hashed_name = $uuid . "." . $extension; // or even not use extension at all, and store it in the DB
@martinbean@snapey no collisions I was just thinking maybe it's more "standardized"? But I guess not
If I do use random string and have a collision - the putFileAs would return false, or will it override an existing file? I know it would never happen in my app, I am just curious
If you were concerned you could put the files in a folder named after the id of the related model which avoids having large numbers of files in a single folder