柔晶美网络工作室

柔晶美网络工作室,倾心于web技术的博客站点

关注我 微信公众号

您现在的位置是: 首页 > 博客日记

dcat admin或laravel admin使用七牛云zgldh/qiniu-laravel-storage组件删除图片报错

2021-03-04 admin laravel  1564

根据官方教程,安装了七牛云存储组件 zgldh/qiniu-laravel-storage,然后配置好 disk,在 config/filesystems.php 添加一项:

'disks' => [
    ... ,
    'qiniu' => [
        'driver'  => 'qiniu',
        'domains' => [
            'default'   => 'xxxxx.com1.z0.glb.clouddn.com', //你的七牛域名
            'https'     => 'dn-yourdomain.qbox.me',         //你的HTTPS域名
            'custom'    => 'static.abc.com',                //你的自定义域名
         ],
        'access_key'=> '',  //AccessKey
        'secret_key'=> '',  //SecretKey
        'bucket'    => '',  //Bucket名字
        'notify_url'=> '',  //持久化处理回调地址
        'url'       => 'http://of8kfibjo.bkt.clouddn.com/',  // 填写文件访问根url
    ],
],

经测试,上传下载和查看都正常,但在后台删除图片文件时,报错了,实际空间里文件已删除,报错内容如下:

Argument 1 passed to zgldh\QiniuStorage\QiniuAdapter::logQiniuError() must be an instance of Qiniu\Http\Error, array given, called in /vendor/zgldh/qiniu-laravel-storage/src/QiniuAdapter.php on line 341

找到上面的报错文件:/vendor/zgldh/qiniu-laravel-storage/src/QiniuAdapter.php,打开后内容如下:

    public function delete($path)
    {
        $bucketMgr = $this->getBucketManager();

        $error = $bucketMgr->delete($this->bucket, $path);
        if ($error !== null) {
            $this->logQiniuError($error, $this->bucket . '/' . $path);

            return false;
        } else {
            return true;
        }
    }

临时解决办法,将341行注释掉即可:

    public function delete($path)
    {
        $bucketMgr = $this->getBucketManager();

        $error = $bucketMgr->delete($this->bucket, $path);
        if ($error !== null) {
            //$this->logQiniuError($error, $this->bucket . '/' . $path);

            return false;
        } else {
            return true;
        }
    }

文章评论


需要 登录 才能发表评论
热门评论
0条评论

暂时没有评论!