Php 显示从google drive检索的图像

Php 显示从google drive检索的图像,php,html,laravel,Php,Html,Laravel,我成功地建立了与google drive的连接,并在上面保存了一个图像。现在我想在我的刀片视图中检索它。不幸的是,我无法将响应放在标记的src中,因为它返回的是图像本身,而不是图像的路径 我尝试使用干预图像包,但当我使用make()方法时,我检查了它,它仍然没有path属性,因此我假设没有任何属性,可以轻松地进行设置。我可以显示没有路径的图像吗?或者,如果可能的话,如何在一行中为返回的图像创建临时路径 我有这个集合中的图像数据 $storage = collect(\Storage::cloud

我成功地建立了与google drive的连接,并在上面保存了一个图像。现在我想在我的刀片视图中检索它。不幸的是,我无法将响应放在
标记的
src
中,因为它返回的是图像本身,而不是图像的路径

我尝试使用干预图像包,但当我使用
make()
方法时,我检查了它,它仍然没有
path
属性,因此我假设没有任何属性,可以轻松地进行设置。我可以显示没有路径的图像吗?或者,如果可能的话,如何在一行中为返回的图像创建临时路径

我有这个集合中的图像数据

$storage = collect(\Storage::cloud()->listContents($this->getGoogleFolderId(), false));
我试图收集尽可能多的信息:

dd($storage->where('name', $breakdowns->first()->image->path025)->first());
返回:

array:10 [▼
  "name" => "2020-10-18-16-46-25-lq.jpg"
  "type" => "file"
  "path" => "1aCS7hRWQWjVwLdF_nn5NKTKJZUbRyq2M/1qTUzjvN6qQBHpGKvN1Xic4SYsVsEgskR"
  "filename" => "2020-10-18-16-46-25-lq"
  "extension" => "jpg"
  "timestamp" => 1603032376
  "mimetype" => "image/jpeg"
  "size" => 59213
  "dirname" => "1aCS7hRWQWjVwLdF_nn5NKTKJZUbRyq2M"
  "basename" => "1qTUzjvN6qQBHpGKvN1Xic4SYsVsEgskR"
]
Intervention\Image\Image {#1562 ▼
  #driver: Intervention\Image\Gd\Driver {#1555 ▼
    +decoder: Intervention\Image\Gd\Decoder {#1567 ▼
      -data: null
    }
    +encoder: Intervention\Image\Gd\Encoder {#1561 ▼
      +result: null
      +image: null
      +format: null
      +quality: null
    }
  }
  #core: gd resource @747 ▼
    size: "1079x1758"
    trueColor: true
  }
  #backups: []
  +encoded: ""
  +mime: "image/jpeg"
  +dirname: null
  +basename: null
  +extension: null
  +filename: null
}
这是:

dd(\IImage::make(\Storage::disk('google')->get($storage->where('name', $breakdowns->first()->image->path025)->first()['path'])));
返回:

array:10 [▼
  "name" => "2020-10-18-16-46-25-lq.jpg"
  "type" => "file"
  "path" => "1aCS7hRWQWjVwLdF_nn5NKTKJZUbRyq2M/1qTUzjvN6qQBHpGKvN1Xic4SYsVsEgskR"
  "filename" => "2020-10-18-16-46-25-lq"
  "extension" => "jpg"
  "timestamp" => 1603032376
  "mimetype" => "image/jpeg"
  "size" => 59213
  "dirname" => "1aCS7hRWQWjVwLdF_nn5NKTKJZUbRyq2M"
  "basename" => "1qTUzjvN6qQBHpGKvN1Xic4SYsVsEgskR"
]
Intervention\Image\Image {#1562 ▼
  #driver: Intervention\Image\Gd\Driver {#1555 ▼
    +decoder: Intervention\Image\Gd\Decoder {#1567 ▼
      -data: null
    }
    +encoder: Intervention\Image\Gd\Encoder {#1561 ▼
      +result: null
      +image: null
      +format: null
      +quality: null
    }
  }
  #core: gd resource @747 ▼
    size: "1079x1758"
    trueColor: true
  }
  #backups: []
  +encoded: ""
  +mime: "image/jpeg"
  +dirname: null
  +basename: null
  +extension: null
  +filename: null
}

以下是我如何处理你的问题。 图像应该已经是您需要的格式

控制器

public function getImage($path)
{
    $filePath = $storage->where('name', $path)->first();

    if(isset($filePath->id)) {
        $disk = Storage::disk('google');
        $image = $disk->get($filePath->{THE ATTRIBUTE ON THAT MODEL WHICH HAS THE GOOGLE PATH});

        return response($image)->header('Content-Type', 'image/png');
    }
}
路线

Route::get('/dynamic-image/{path}', 'ImageController@getImage');
<img src="/dynamic-image/{{$bd->image->path025}}">
刀片

Route::get('/dynamic-image/{path}', 'ImageController@getImage');
<img src="/dynamic-image/{{$bd->image->path025}}">
image->path025}>

你想直接从谷歌云服务图像,还是想下载到你的服务器上然后显示它?如果可能的话只显示它。我试着在blade中这样内联它,到目前为止不起作用
get($storage->where('name',$bd->image->path025)->first()['path'])->header('Content-Type',image/png')}alt razobok“height=“50”>
你不能这样做,你需要一个请求才能去拍摄这张图片,我会编辑我的回答你应该能够编辑
$storage
部分,在你使用它时工作,我的部分只是一个例子,当然变量没有设置在任何地方,我会在早上第一件事尝试它,这样我就可以检查你的答案是否正确。非常感谢。