Note that there are some explanatory texts on larger screens.

plurals
  1. PORails - hide file url from users (rails 3.1 + carrierwave + google storage for developers)
    primarykey
    data
    text
    <p>I've built an application, deployed on heroku, that uses carrierwave to keep all uploaded files and I've set google storage for developers for keeping those files there.</p> <p>Until here everything is working fine, but I would like to keep files showing private, ie. user must be authorized to view. In the development environment everything works very well. </p> <p>In order to hide the file source url from users I took the following decisions:</p> <p><strong>initializers / carrierwave.rb</strong></p> <pre><code>CarrierWave.configure do |config| if Rails.env.production? config.storage = :fog config.fog_credentials = { :provider =&gt; 'Google', :google_storage_access_key_id =&gt; 'xxx', :google_storage_secret_access_key =&gt; 'yyy' } config.fog_directory = 'wwww' else config.storage = :file end end </code></pre> <p><strong>controller</strong></p> <p>This gets the file contents in order to hide its path and name from public eyes</p> <pre><code>def get_file if Rails.env.production? redirect_to URI.encode @media_asset.attachment_url else send_file ("public/"+@media_asset.attachment_url.to_s), :type =&gt; @media_asset.attachment_content_type, :length =&gt; @media_asset.attachment_file_size, :status =&gt; "200 OK", :x_sendfile =&gt; true, :filename =&gt; "media_asset", :disposition =&gt; 'inline' end end </code></pre> <p>apparently this would do the job, but using a normal browser developer tool, everybody would see the path to the google storage bucket and would be able to access all files.</p> <p>Do you have a clue on how to resolve this issues, is it even possible to do with google storage for developers?</p> <p>thanks in advance,</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload