title: Store S3 URL in database table
body: <p>I'm building a small asset management system in Laravel 5.2</p>
  
  <p>A user can upload images, video etc to the app and the asset meta data gets stored in the assets table. While that's happening, the asset is renamed to match the asset id (I'm storing the original filename too), I'm storing the mime type and uploading the file to S3.</p>
  
  <p>Where I've come unstuck is storing the S3 url in database.</p>
  
  <p>This is my method</p>
  
  <pre><code>public function store(AssetRequest $request)
      {
  
          // Initialise new asset and set the name
          // from the form
          $asset = new Asset(array(
              'name' =&gt; $request-&gt;get('name')
          ));
  
          $asset-&gt;user_id = Auth::user()-&gt;id;
  
          // save the asset to the db
          $asset-&gt;save();
          // set the file var = form input
          $file = $request-&gt;file('asset_path');
          $extension = $file-&gt;getClientOriginalExtension();
          // modify the asset name
          $assetFile = $asset-&gt;id . '.' . $request-&gt;file('asset_path')-&gt;getClientOriginalExtension();
          // push the new asset to s3
          Storage::disk('s3')-&gt;put('uploads/' . $assetFile, file_get_contents($file));
          $asset-&gt;mime = $file-&gt;getClientMimeType();
          $s3Url = Storage::url($file);
          $asset-&gt;s3_url = $s3Url;
          $asset-&gt;original_filename = $file-&gt;getClientOriginalName();
          $asset-&gt;filename = $assetFile;
          $asset-&gt;file_extension = $extension;
          // return ok
          $asset-&gt;save();
          return \Redirect::route('asset.create')-&gt;with('message', 'Asset added!');
      }
  </code></pre>
  
  <p>The lines relating to my attempt at storing the S3 url</p>
  
  <p><code>
  $s3Url = Storage::url($file);
  $asset-&gt;s3_url = $s3Url;
  </code>
  Only seems to store a temporary path <code>/storage//tmp/php8su2r0</code> rather than an actual S3 url. I'd like to avoid having to set the bucket manually, rather hoping I can use what is configured in <code>config/filesystem.php</code></p>
  
  <p>Any ideas? </p>