wip stograge
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
|
||||
export function imgurl(channel,record) {
|
||||
|
||||
if (record._file.mime === "image/svg+xml") {
|
||||
return fileurl(channel, record);
|
||||
}
|
||||
return channel.filesUrl + `/thumbs/${record._file.path}`;
|
||||
return channel.filesUrl + `/thumbs/${record._file.disk}/${record._file.path}`;
|
||||
}
|
||||
|
||||
export function fileurl(channel, record) {
|
||||
return channel.filesUrl + `/${record._file.path}`;
|
||||
return channel.filesUrl + `/${record._file.disk}/${record._file.path}`;
|
||||
}
|
||||
|
||||
export function htmlurl(channel,record, preset) {
|
||||
@@ -19,7 +18,7 @@ export function htmlurl(channel,record, preset) {
|
||||
if (record._file.width > 0) {
|
||||
let presetUrl = url;
|
||||
if (preset) {
|
||||
presetUrl = channel.filesUrl + `/templates/${preset}/${record._file.path}`;
|
||||
presetUrl = channel.filesUrl + `/templates/${preset}/${record._file.disk}/${record._file.path}`;
|
||||
}
|
||||
|
||||
html = `<img src="${presetUrl}" alt="${record._file.path}" />`
|
||||
|
||||
@@ -85,6 +85,7 @@ class FileService
|
||||
originalName: $originalFilename,
|
||||
mime: $mimetype,
|
||||
path: $path,
|
||||
disk: $schema->disk,
|
||||
size: $file->getSize(),
|
||||
width: $width,
|
||||
height: $height,
|
||||
@@ -109,9 +110,9 @@ class FileService
|
||||
return in_array($mimetype, $imageMimes);
|
||||
}
|
||||
|
||||
public function loadDisk(Schema $schema): Filesystem
|
||||
public function loadDisk(Schema|string $schema): Filesystem
|
||||
{
|
||||
return Storage::disk($schema->disk);
|
||||
return Storage::disk($schema->disk ?? $schema);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,20 @@ class FileController extends Controller
|
||||
return response()->file($disk->path("templates/".$templatePath));
|
||||
}
|
||||
|
||||
public function original(Request $request, string $disk)
|
||||
{
|
||||
$imagePath = $request->route("any");
|
||||
$disk = $this->fileService->loadDisk($disk);
|
||||
return response()->file($disk->path($imagePath));
|
||||
}
|
||||
|
||||
public function thumb(Request $request, string $disk)
|
||||
{
|
||||
$imagePath = "thumbs/".$request->route("any");
|
||||
$disk = $this->fileService->loadDisk($disk);
|
||||
return response()->file($disk->path($imagePath));
|
||||
}
|
||||
|
||||
public function download(Request $request)
|
||||
{
|
||||
$disk = $this->fileService->loadDisk();
|
||||
|
||||
+2
-1
@@ -15,7 +15,8 @@ use Lucent\Http\Controller\SetupController;
|
||||
|
||||
Route::get('/lucent/setup', [SetupController::class, 'setup']);
|
||||
Route::get('/storage/templates/{any}', [FileController::class, 'template'])->where('any', '.*');
|
||||
//Route::get('/storage/thumbs/{any}', [FileController::class, 'thumb'])->where('any', '.*');
|
||||
Route::get('/lfs-{disk}/thumbs/{any}', [FileController::class, 'thumb'])->where('any', '.*');
|
||||
Route::get('/lfs-{disk}/{disk}/{any}', [FileController::class, 'original'])->where('any', '.*');
|
||||
|
||||
Route::group([
|
||||
'middleware' => ['web'],
|
||||
|
||||
@@ -10,6 +10,7 @@ class FileData
|
||||
public readonly string $originalName,
|
||||
public readonly string $mime,
|
||||
public readonly string $path,
|
||||
public readonly string $disk,
|
||||
public readonly int $size,
|
||||
public readonly int $width,
|
||||
public readonly int $height,
|
||||
@@ -24,6 +25,7 @@ class FileData
|
||||
originalName: data_get($data, "originalName"),
|
||||
mime: data_get($data, "mime"),
|
||||
path: data_get($data, "path"),
|
||||
disk: data_get($data, "disk", "lucent"),
|
||||
size: data_get($data, "size"),
|
||||
width: data_get($data, "width"),
|
||||
height: data_get($data, "height"),
|
||||
|
||||
@@ -54,7 +54,7 @@ class Record implements JsonSerializable
|
||||
$file = json_decode($data->_file, true);
|
||||
if (!empty($file)) {
|
||||
|
||||
$file = new FileData(...$file);
|
||||
$file = FileData::fromArray($file);
|
||||
} else {
|
||||
$file = null;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class RevisionRepo
|
||||
$file = json_decode($data->_file, true);
|
||||
if (!empty($file)) {
|
||||
|
||||
$file = new FileData(...$file);
|
||||
$file = FileData::fromArray($file);
|
||||
} else {
|
||||
$file = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user