首页 > 解决方案 > 图像源不可读(我做错了什么)?

问题描述

我正在尝试将我的图像存储在 Aws 上并将其显示在我的博客页面上。

我立即发布了图像,它显示了这一点Image source not readable,但图像以正确的图像名称保存在 aws s3 存储桶中。

控制器

private function storeImage($post)
    {
        if (request()->hasFile('image')){

            $original = request()->file('image')->getClientOriginalName();

            $post->update([
                'image' => request()->file('image')->storeAs('uploads', $original),
            ]);

            $image = Image::make(public_path('image/'. $post->image));
            $image->save();
        }

文件系统.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default filesystem disk that should be used
    | by the framework. The "local" disk, as well as a variety of cloud
    | based disks are available to your application. Just store away!
    |
    */

    'default' => env('FILESYSTEM_DRIVER', 's3'),

    /*
    |--------------------------------------------------------------------------
    | Default Cloud Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Many applications store files both locally and in the cloud. For this
    | reason, you may specify a default "cloud" driver here. This driver
    | will be bound as the Cloud disk implementation in the container.
    |
    */

    'cloud' => env('FILESYSTEM_CLOUD', 's3'),

    /*
    |--------------------------------------------------------------------------
    | Filesystem Disks
    |--------------------------------------------------------------------------
    |
    | Here you may configure as many filesystem "disks" as you wish, and you
    | may even configure multiple disks of the same driver. Defaults have
    | been setup for each driver as an example of the required options.
    |
    | Supported Drivers: "local", "ftp", "sftp", "s3"
    |
    */

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => public_path('image/'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
        ],

    ],

];

<img class="post-image rectangle" src="{{ secure_asset('image/' . $post->image ) }}">

我做错了什么,因为它保存在我的 aws s3 存储桶中,但出现上述错误,我需要帮助?

标签: laravelamazon-s3

解决方案


推荐阅读