KharNam's avatar

Get url image when upload with GoogleDriveService

Hi everyone, I am using google drive as the photo storage of the application after uploading, but I have trouble trying to get the image path after uploading. How can I get the link? This is my code upload

$name = $request->file('thumbnail')->getClientOriginalName();
$image=  $request->file('thumbnail')->storeAs('/', $name, 'google');

If i use Storage::disk('google')->allFiles() . I get the following array

[
  0 => "130JDj2AYUyQd-9ABLHW86wXjtHdIOWdJ"
  1 => "1irMQMcYqnt8DSszOEqPKE5a7D30rib30"
]

I know it is random name, the photos I uploaded. but i need the url of each picture. What should I do ? thanks

0 likes
1 reply
neilstee's avatar

@kharnam you can try this:

$files = Storage::disk('google')->allFiles();
$urls = [];
foreach ($files as $file) {
	$urls[] = Storage::disk('google')->url($name);
}

dd($urls);

Please or to participate in this conversation.