lots
This commit is contained in:
@@ -3,18 +3,27 @@
|
||||
namespace Lucent\File;
|
||||
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Lucent\Channel\ChannelService;
|
||||
use Lucent\LucentException;
|
||||
use Lucent\Record\File;
|
||||
use Lucent\Record\QueryRecord;
|
||||
use Lucent\Schema\Schema;
|
||||
use Lucent\Schema\Type;
|
||||
|
||||
class FileService
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
public function __construct(
|
||||
public ChannelService $channelService
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public function getPath(QueryRecord $file): string
|
||||
{
|
||||
return $this->channelService->channel->url. "/storage/".$file->_file->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws LucentException
|
||||
*/
|
||||
|
||||
+11
-9
@@ -102,7 +102,7 @@ function checkDuplicate(string $schemaName, string $checksum, int $filesize): st
|
||||
{
|
||||
|
||||
$record = DB::table("records")
|
||||
->where("_sys->schema", $schemaName)
|
||||
->where("schema", $schemaName)
|
||||
->where("_file->checksum", $checksum)
|
||||
->where("_file->size", $filesize)
|
||||
->first();
|
||||
@@ -112,22 +112,24 @@ function checkDuplicate(string $schemaName, string $checksum, int $filesize): st
|
||||
|
||||
function createThumbnail(Filesystem $disk, string $schemaPath, string $filename, UploadedFile $file): void
|
||||
{
|
||||
|
||||
|
||||
$thumbDir = storage_path("app/public/thumbs/" . $schemaPath . "/");
|
||||
if (!file_exists($thumbDir)) {
|
||||
make_dir_r($thumbDir);
|
||||
}
|
||||
|
||||
try {
|
||||
$image = ImageManagerStatic::make($file);
|
||||
} catch (Exception $e) {
|
||||
logger($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
$image->fit(300, 300);
|
||||
try {
|
||||
$image->encode('webp', 75);
|
||||
|
||||
$disk->put(
|
||||
"thumbs/" . $schemaPath . "/" . $filename,
|
||||
$image,
|
||||
// 'public' // now managed by aws policy
|
||||
);
|
||||
|
||||
$image->encode('webp', 75)->save($thumbDir .$filename);
|
||||
} catch (Exception $e) {
|
||||
logger($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user