mirror of
https://github.com/sakaljurgis/actions-api.git
synced 2026-11-06 16:08:01 +00:00
initial commit
This commit is contained in:
commit
6df493fab3
86 files changed
+11890
No files matched your search
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Image;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ImageService
|
||||
{
|
||||
/**
|
||||
* @param string $base64ImageData
|
||||
* @param string $mimeType
|
||||
* @return array ['url', 'id']
|
||||
*/
|
||||
public function saveImage(string $base64ImageData, string $mimeType): array
|
||||
{
|
||||
$imageId = uniqid();
|
||||
$imageData = base64_decode($base64ImageData);
|
||||
$ext = explode('/', $mimeType)[1];
|
||||
|
||||
Storage::put('public/images/' . $imageId . '.' . $ext , $imageData);
|
||||
$relativePath = Storage::url('public/images/' . $imageId . '.png');
|
||||
|
||||
return [
|
||||
'url' => asset($relativePath),
|
||||
'id' => $imageId,
|
||||
// todo - size, width, height, thumb, etc
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user