我正在尝试集成spamedia媒体库软件包,以使用cloudinary托管和提供图像。
该软件包不支持cloudinary,所以我不得不使用另一个旧软件包:flysystem-cloudinary
[我还跟踪了关于stackoverflow的讨论,其中有人也与之抗争:spatie-cloudinary
我设法将图像上传到cloudinary,但是当我尝试检索它时,出现此错误:
App \ Cloudinary \ CloudinaryUrlGenerator :: getTemporaryUrl()的声明:字符串必须与Spatie \ MediaLibrary \ UrlGenerator \ UrlGenerator :: getTemporaryUrl(DateTimeInterface $ expiration,array $ options = Array):string兼容)>
这是我的CloudinaryUrlGenerator:
<?php namespace App\Cloudinary; use Spatie\MediaLibrary\UrlGenerator\BaseUrlGenerator; class CloudinaryUrlGenerator extends BaseUrlGenerator { const HOST = 'https://res.cloudinary.com/'; /** * Get the url for a media item. * * @return string */ public function getUrl(): string { $cloudBaseUrl = self::HOST . config('filesystems.disks.cloudinary.cloud_name') . '/'; $options = [ 'q_auto', ]; $filePathIncludingFilenameAndExtension = '/' . $this->pathGenerator->getPath($this->media) . $this->media->file_name; return $cloudBaseUrl . implode(',', $options) . $filePathIncludingFilenameAndExtension; } /** * Get the temp url for a media item. * * @return string */ public function getTemporaryUrl(): string { return $this->getUrl(); } /** * Get the responsive images directory url for a media item. * * @return string */ public function getResponsiveImagesDirectoryUrl(): string { return $this->getUrl(); } }
我尝试使用函数定义,但没有解决。
我正在尝试集成spamedia媒体库软件包以使用cloudinary托管和提供图像。该软件包不支持cloudinary,因此我不得不使用另一个旧软件包:flysystem-cloudinary I ...