laravel - 图像源不可读(我做错了什么)?
问题描述
我正在尝试将我的图像存储在 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 存储桶中,但出现上述错误,我需要帮助?
解决方案
推荐阅读
- ubuntu - 基于 PKI 的网站身份验证的证书问题
- android - 通过在 Android 中归档 ffmpeg/ffprobe 库来减小应用程序大小
- azure - 无法在具有 .NET 核心应用程序的构造函数中将 PlatformParameter 与单个参数一起使用
- pandas - 如何使用 Pandas Dataframe 替换文本值并保持数据类型
- docker - 如何在运行时将数据源密码传递给 websphere 自由容器
- javascript - 使用扩展运算符简化代码
- git - 如何将 dll 部署到 Nexus 存储库
- java - 通过意图传递 mutableList
- css - 如何组合多个 CSS 媒体查询“组”?
- c# - 对象未正确移向其他对象位置 - Vector3.MoveTowards