You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB
PHTML

2 years ago
<?php
namespace App\Http\Controllers;
use App\Services\CrossFileService;
use Illuminate\Http\Request;
class AssetController extends Controller
{
public function upload(Request $request, CrossFileService $fileService)
{
$asset = $fileService->saveFile(auth()->user(), $request, "file");
$data = [
'uid' => $asset->uid,
'url' => '/image/rate/w800/'. $asset->uid,
];
return $this->sendJson('업로드 완료', 'success', $data, [], true);
}
public function download($uid, CrossFileService $fileService)
{
return $fileService->download($uid);
}
public function downloadImageRate($rate, $uid, CrossFileService $fileService)
{
if (!empty($rate)) {
$type = substr($rate, 0, 1);
$size = substr($rate, 1);
if ($type == 'w' || $type == 'h') {
return $fileService->downloadImageRate($uid, $type, $size);
}
}
abort(404);
}
public function downloadImage($size, $uid, CrossFileService $fileService)
{
if (!empty($size)) {
$size = explode("x", $size);
$width = (int)$size[0];
$height = (int)$size[1];
return $fileService->downloadImage($uid, $width, $height);
}
abort(404);
}
}