我想通过路由访问laravel公共文件夹中存储的图像,以防万一搜索我的公共文件夹中是否存在图像,这是到目前为止的代码:
api.php
Route::group(['prefix' => 'images', 'middleware' => 'cors'], function () {
Route::get('itemsImages/{imagename}','ManagerController@itemImage');
});
ManagerController.php
public function itemImage($imagename)
{
// Check if file exists in storage directory
$file_path = public_path() .'/images/itemsImages/'.$imagename;
if (file_exists($file_path))
return Response::download($file_path);
else
dd($file_path);
//does not exist
}
但是该代码不起作用,甚至无法访问路由,感谢您的任何帮助。
答案 0 :(得分:0)
我认为这可能有效
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
creationTimestamp: "2019-04-03T12:44:22Z"
generation: 1
labels:
chart: app-1.1
component: app
hostName: app.client.com
release: app
name: app-ingress
namespace: default
resourceVersion: "1789269"
selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/app-ingress
uid: 34bb1a1d-560e-11e9-bd46-9a03420914b9
spec:
rules:
- host: app.client.com
http:
paths:
- backend:
serviceName: app-service
servicePort: 8080
path: /app1
tls:
- hosts:
- app.client.com
secretName: app-prod
status:
loadBalancer:
ingress:
- {}
我还没有测试上面的代码,所以请告诉我是否适合您。