Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A place to store file ( Ruby on Rails )

I'm new to Rails, I wanted to make a website for uploading files: music, videos, pictures, text. What is a better way to store files? I've read about different methods: Database, as a file, Amazon S3?

There will be a lot of files around 1 kb to 20Mb each.

Thanks!

like image 420
makrusak Avatar asked Dec 30 '25 02:12

makrusak


1 Answers

Storing files in a database is not bad, per se. It depends on the kind of database.

Storing files in a relational database is not view as a good practice by the reasons explained by bassneck.

But there are other kind databases that are specifically designed to store any kind of data, in a non-relational way, for example files of any kind. The answer of Dhruva highlight that, MongoDB is pretty good and its support for storing files using GridFS is awesome.

GridFS is very good, for example it can stream only parts of a file, pretty useful for video.

In your specific case – many small files of many kinds of data – GridFS is an real option. I use Heroku & mongohq.com and they work like a charm.

like image 191
Nerian Avatar answered Dec 31 '25 17:12

Nerian