Aliyun-oss-storage
Aliyun-oss-storage copied to clipboard
ErrorException In AliOssAdapter.php line 570
public function getUrl( $path ) { if (!$this->has($path)) throw new FileNotFoundException($filePath.' not found'); //这句报错了,FileNotFoundException没有找到 2$filePath 没有定义 return ( $this->ssl ? 'https://' : 'http://' ) . ( $this->isCname ? ( $this->cdnDomain == '' ? $this->endPoint : $this->cdnDomain ) : $this->bucket . '.' . $this->endPoint ) . '/' . ltrim($path, '/'); }
我也遇到这个问题了; Class 'Symfony\Component\Filesystem\Exception\FileNotFoundException' not found /vendor/jacobcyl/ali-oss-storage/src/AliOssAdapter.php 570行
同,请问解决了吗?
同,请问解决了吗?
注释掉 570行代码,不检查文件是否存在
检查路径是否有问题,比如多个“/”
这个建议作者去掉 has($path) 的判断。 因为图片或内容不存在就抛出异常,太不友好了。 数据量大也影响访问。
同问,这个有更新解决吗?
同问,这个有更新解决吗?
查看返回url地址是否多了「/」 form->image('column', __('图片'))->move("xxx/xxx"); 最后不要带「/」,否则上传oss成功后,查看时报错
\Encore\Admin\Grid\Column::extend('image', \App\Admin\Extensions\MyImage::class);
class MyImage extends AbstractDisplayer
{
public function display($server = '', $width = 200, $height = 200)
{
if ($this->value instanceof Arrayable) {
$this->value = $this->value->toArray();
}
return collect((array) $this->value)->filter()->map(function ($path) use ($server, $width, $height) {
if (url()->isValidUrl($path) || strpos($path, 'data:image') === 0) {
$src = $path;
} elseif ($server) {
$src = rtrim($server, '/').'/'.ltrim($path, '/');
} else {
//自定义方法添加路由
$src = getOssUrl($path);
}
return "<img src='$src' style='max-width:{$width}px;max-height:{$height}px' class='img img-thumbnail' />";
})->implode(' ');
}
}