代码之家  ›  专栏  ›  技术社区  ›  jeff923

通过api上传到Google Drive后,如何获取文件的链接?

  •  0
  • jeff923  · 技术社区  · 8 年前

    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 回复  |  直到 8 年前
        1
  •  1
  •   PKeidel    8 年前

    你在laravel文档中查过了吗?

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

    对于您的代码,您应该使用以下内容:

    use Illuminate\Support\Facades\Storage;
    
    $url = Storage::disk('google')->url('img.png');
    
    dd($url);
    
    推荐文章