如何通过api上传到Google云端硬盘后获取该文件的链接?

时间:2017-10-21 22:53:56

标签: php laravel-5 google-drive-api google-cloud-datastore

我正在遵循本指南。我可以将图像上传到我的谷歌硬盘,但我无法获取文件的路径。

https://gist.github.com/ivanvermeyen/cc7c59c185daad9d4e7cb8c661d7b89b

// Get img that was uploaded to my server
$img = request()->file('img');

// Save that image to my google drive
Storage::disk('google')->put('img.png', fopen($img, 'r+'));

// ?? how do I get the path to the file so I can save it in my database?

1 个答案:

答案 0 :(得分:0)

您是否在laravel文档中查找过它?

https://laravel.com/docs/5.5/filesystem#file-urls

对于您的代码,您应该使用:

use Illuminate\Support\Facades\Storage;

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

dd($url);