Protect images uploaded with Carrierwave

66 views
Skip to first unread message

Ragesh R.

unread,
Aug 22, 2015, 5:47:23 AM8/22/15
to rubyonra...@googlegroups.com
I want to protect certain images from download. Only authorized users
would be able to download them.

As I upload images with Carrierwave, they are stored inside
public/uploads/image. Users can download them via urls.

How can I protect images inside image folder so anonymous users can't
access them?
I know I can make before_action which wont allow anonymous user to
download it via download link but the image is still accessible if the
user knows path to the folder where are images stored.
pls help me to find a solution

--
Posted via http://www.ruby-forum.com/.

Elizabeth McGurty

unread,
Aug 22, 2015, 7:22:53 AM8/22/15
to Ruby on Rails: Talk
In your routes.rb are you making public/uploads/image available?  run rake routes.  Otherwise, I would simply move your files out of public/uploads/image and create a 'private' folder within or outside your App.   Then I would cease in informing the public where your image files are stored. ;)

Bjørn Michelsen

unread,
Aug 22, 2015, 3:09:24 PM8/22/15
to rubyonra...@googlegroups.com
On Sat, Aug 22, 2015 at 11:46:42AM +0200, Ragesh R. wrote:

Hey there,

> I want to protect certain images from download. Only authorized users
> would be able to download them.
>
> As I upload images with Carrierwave, they are stored inside
> public/uploads/image. Users can download them via urls.
>
> How can I protect images inside image folder so anonymous users can't
> access them?
> I know I can make before_action which wont allow anonymous user to
> download it via download link but the image is still accessible if the
> user knows path to the folder where are images stored.

Did you try any of the options listed in the documentation? If not, have
a look at

https://github.com/carrierwaveuploader/carrierwave/wiki/how-to:-secure-upload

--
Sincerely,
Bjorn Michelsen
Reply all
Reply to author
Forward
0 new messages