Set path for original images using paperclip in Rails?

后端 未结 2 388
再見小時候
再見小時候 2020-12-24 09:27

The situation

I have a simple model with an attached image using paperclip, which has a couple of processed styles for it (thumbnail, full, feature). At this point

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-24 10:20

    If it is acceptable, you could skip saving the originals, by setting the default style.

      has_attached_file :image,
                        :styles => { :normal => "800x600>" },
                        :default_style => :normal
    

    If not, and you want to keep the originals, if you are using apache, you could use a .htaccess file to restrict the access to the originals directory

    
       Order allow,deny
       Deny from all
    
    

提交回复
热议问题