开发者

How do I add file uploads to a rails app?

开发者 https://www.devze.com 2023-01-17 05:35 出处:网络
I need to add the ability to upload and store an开发者_StackOverflowy kind of file, PDF, XLS, DOC, etc. What is the best way to do this in a ruby on rails application?I think this is exactly what you\

I need to add the ability to upload and store an开发者_StackOverflowy kind of file, PDF, XLS, DOC, etc. What is the best way to do this in a ruby on rails application?


I think this is exactly what you're looking for.

Upload files.


I'd recommend you to use paperclip or carrierwave both are really good libs and work out of the box in most cases.


you can also look at attachment_fu rails.


I've worked with two of the big players when it comes to file uploads. carrierwave and paperclip.

They provide a good solution for a common task with support for different storage alternatives. Both support filesystem and S3. Carrierwave also supports Rackspace Cloud Files and MongoDB’s GridFS.

I would recommend carrierwave because of one aspect where they are different to use. It uses a separate upload class that you mount on your model. This separates your code related to the file upload from the model code. I find this approach cleaner and easier to test.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号