How to get url image when upload with GoogleDriveService

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

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You can use FilesystemReader::listContents

Storage::disk('google')->listContents();

or

use IlluminateSupportFacadesStorage;

$url = Storage::disk('google')->url('img.png');

dd($url);

or

You can use the below code.

$disk = Storage::disk('google');
$url = $disk->url('foo.jpg');


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x