makrusak
makrusak

Reputation: 459

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!

Upvotes: 3

Views: 1814

Answers (5)

Bernard Banta
Bernard Banta

Reputation: 755

I would recommend you use amazon s3 to store your files. It is the best.

Upvotes: 0

Nerian
Nerian

Reputation: 16177

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.

Upvotes: 3

Dhruva Sagar
Dhruva Sagar

Reputation: 7307

I will suggest you to also check out & consider MongoDB GridFS - http://www.mongodb.org/display/DOCS/GridFS+Specification. My experience with GridFS has been good. I cannot give you a comparative analysis with the other options, however I would like to know the same.

Upvotes: 2

bassneck
bassneck

Reputation: 4043

I don't think there is a right answer for that. I use heroku, so my only option is Amazon S3 (which has free quotas for the first year) and I'm pretty satisfied with it. I use carrierwave gem for uploading files and it's really easy to use. I really prefer it over Paperclip.

If your hosting provides a lot of space and bandwidth then you could give it a try.

But for the database, I really don't like the idea of storing files in it.

Updated

Reading a filename from the table should be faster than reading the file itself. The bigger the DB, the longer it will take to make a backup. And if you take heroku for example, you only get 20gb for a shared db. That's not much if you're gonna store 10-20mb files in there. Moving project to another hoster might be easier if you store files in the DB. But if you use an external service (such as S3), there would be no difference for you.

Upvotes: 3

Robert B
Robert B

Reputation: 2883

Amazon S3 integration on Heroku is relatively easy to setup and get working with the paperclip gem. Heroku has some documentation on how to get this up and running.

Take a look at their documentation and see if this is the kind of thing your looking for.

http://devcenter.heroku.com/articles/s3

Upvotes: 2

Related Questions