Upload beautify
This commit is contained in:
21
app/Services/Uploads/UploadHashService.php
Normal file
21
app/Services/Uploads/UploadHashService.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Services\Uploads;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
final class UploadHashService
|
||||
{
|
||||
public function hashFile(string $path): string
|
||||
{
|
||||
$hash = hash_file('sha256', $path);
|
||||
|
||||
if ($hash === false) {
|
||||
throw new RuntimeException('Failed to hash upload file.');
|
||||
}
|
||||
|
||||
return $hash;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user