首页 > 解决方案 > AWS Elastic Beanstalk Laravel 禁止获取文件

问题描述

我在 aws elastic beanstalk 中部署 laravel,我已经成功设置了数据库和项目,并避免使用 storage:link 和我使用路由获取文件的那种(图像,即)。像这样:

Route::get('storage/{folder}/{filename}', function ($folder,$filename)
{
    // Add folder path here instead of storing in the database.
    $path = storage_path('app/public/'.$folder.'/' . $filename);

    if (!File::exists($path)) {
        abort(404);
    }

    $file = File::get($path);
    $type = File::mimeType($path);

    $response = Response::make($file, 200);
    $response->header("Content-Type", $type);

    return $response;
}); 

所以...我有 2 个不同的项目,在 laravel 中具有相同的基本配置(app.php、database.php、.env 等),在 aws 中有相同的环境和应用程序配置,但在一个我获得图像访问和在另一个我得到

Forbidden

You don't have permission to access /storage/productos/pruebalibro.pdf on this server.

一些虽然?我可以检查或做什么?我知道 aws 在 ec2 和其他东西中创建东西,但我应该研究什么?

标签: phplaravelamazon-web-servicesamazon-elastic-beanstalk

解决方案


推荐阅读