title: Confirming when PHP's `file_put_contents()` is complete
body: <p>In my Laravel app, I'm using streaming to download large files (> 1GB) to my server for additional processing:</p>
  
  <pre><code>    $stream = Storage::disk('google')-&gt;getDriver()-&gt;readStream($file['path']);
      file_put_contents(public_path("files/{$filename}.tiff"), stream_get_contents($stream));
  
      if (file_exists(public_path("files/{$filename}.tiff"))) {
          ConvertTIFF::dispatch();
          return;
      }
  </code></pre>
  
  <p>The problem is that, because I'm streaming the file, the file itself gets created long before the streaming process is actually complete. So my <code>file_exists()</code> check will frequently fire my <code>ConvertTIFF</code> event before the file is complete.</p>
  
  <p>Is there a simpler way to check that the <code>file_put_contents()</code> streaming process is complete? Or is there a way to make the process blocking, so there's no danger of the event before fired before the file is fully downloaded?</p>