This commit is contained in:
Kekskurse 2019-12-25 19:33:53 +01:00
parent bf611c5529
commit 8ff1dee767
2 changed files with 26 additions and 0 deletions

View File

@ -208,6 +208,31 @@ class AppController extends BaseController
return $response->withData(["url" => $result['ObjectURL']]);
}
public function getAppIcon($id) {
$app = \App\Models\App::query()->where("id", "=", $id)->firstOrFail();
if(!is_dir(storage_path("icon"))) {
mkdir(storage_path("icon"));
}
$cacheFile = storage_path("icon/".$app->id.".png");
if(file_exists($cacheFile)) {
$icon = file_get_contents($cacheFile);
} else {
if(!empty($app->iconURL)) {
$icon = file_get_contents($app->iconURL);
file_put_contents($cacheFile, $icon);
} else {
$icon = file_get_contents(resource_path("images/app.png"));
}
}
$r = getimagesizefromstring($icon);
return response($icon)
->header('Content-Type',$r["mime"]);
}

View File

@ -58,6 +58,7 @@ $router->group(['prefix' => 'api'], function () use ($router) {
$router->post("/", ['uses' => 'API\AppController@createApp']);
$router->get("/find", ['uses' => 'API\AppController@findApp']);
$router->group(['prefix' => '{id}'], function () use ($router) {
$router->get("/icon", ["uses" => "API\AppController@getAppIcon"]);
$router->get("/", ['uses' => 'API\AppController@appDetails']);
$router->put("/", ['uses' => 'API\AppController@updateApp']);
$router->get("/access", ["uses" => "API\oAuthController@getAccess"]);