title: Laravel download from google drive (filesystem) or (hide api key from link)
body: <p>First way to download:</p>
  
  <blockquote>
    <ol>
    <li><a href="https://www.googleapis.com/drive/v3/files/1YIH4zfM0P1xa-_mfZNGiIY8qZrIEt-rF/?key=API_KEY&amp;alt=media" rel="nofollow noreferrer">https://www.googleapis.com/drive/v3/files/1YIH4zfM0P1xa-_mfZNGiIY8qZrIEt-rF/?key=API_KEY&amp;alt=media</a></li>
    </ol>
  </blockquote>
  
  <p>Putting my API KEY in the link it gives me ability to download the file directly from my google drive.But I don't want to give my API_KEY to the users.</p>
  
  <blockquote>
    <p>2.I can also access my drive another way: (<code>using nao-pon/flysystem-google-drive</code>)</p>
  </blockquote>
  
  <pre><code>Route::get('/download/{rest?}', function ($rest) {
      $metadata = Storage::cloud()-&gt;getMetadata($rest);
      $readStream = Storage::cloud()-&gt;getDriver()-&gt;readStream($rest);
  
      return response()-&gt;stream(function () use ($readStream) {
          fpassthru($readStream);
      }, 200, [
          'Content-Type' =&gt; $metadata['mimetype'],
          'Content-disposition' =&gt; 'attachment; filename="'.$metadata['name'].'"', // force download?
      ]);
  })-&gt;where('rest','(.*)');
  </code></pre>
  
  <p>This way I don't have to use api_key but the server has to download the whole file it's a stream but still that uses server resources.</p>
  
  <p>On the other hand <code>https://www.googleapis.com/drive/v3/files/1YIH4zfM0P1xa-_mfZNGiIY8qZrIEt-rF/?key=API_KEY&amp;alt=media</code> needs Content-Type and File name as it doesn't have on it.And also I have no idea how to hide the api key.</p>
  
  <p>So what do you suggest.Is there any other way not to response()->stream to not download the whole file by stream through server and then send it to the user?Multiple users downloading the files would use all the bandwidth,so the download speed drops so fast.</p>