© 2013 All rights reserved.
0

CarrierWave: Fog and File Storage combination

Currently on a project that we do, where we use for upload files CarrierWave gem, we need to combine: Fog and: File storage by the environment settings.
EarnOnMe

The system (EarnOnMe) is hosted in Heroku where we can’t use file storage, so we use storage from Amazon (Amazon S3), where we store mostly pictures.

 

We have two servers, test, and production. The test server replicate every day production database as self (we need to test on real data). The condition is that the test server can’t directly access the S3 storage to avoid overwriting files when uploading, but must have access to this data when downloading them (must display images from replicated database).

 

Upload settings for the controller is simple, but the type of storage is saved in the environment settings.

 

test_uploader.rb

To testing application in test mode we can only rewrite the test.rb (or development.rb to testing in dev mode) loading images directly from S3:

 

production.rb

test.rb

development.rb

Comments are closed for this page

About
Hi, i am programmer from the Czech Republic. I love web development (Ruby, Ruby on Rails, PHP, Nette) and iOS development (Objective-C, Cocoa).
To cooperate, here is my phone:
+420 608 836