I've looked at the available options and it seems like everything is optimized for image uploading as display. I just need simple file upload and retrieval. Are there any good options?
Paperclip is a popular choice for uploading and sizing images, but you can upload any type of file with it (doc, zip, txt, pdf... anything). Highly recommended. https://github.com/thoughtbot/paperclip
I like carrierwave. It has built in support for s3, has no workaround for setting up apps on heeroku unlike paperclip.
I use Carrierwave for mine and have been happy with it. I am just uploading general files, not specifically images. It is easy to implement and has good advanced features if you need them later. It also integrates with Fog to make using remote storage sources (like s3 or rackspace cloud files) easy.
Carrierwave benefits:
With carrierwave, the attachment is a seperate model instead of an attribute on an existing model, which might make things cleaner to work with.
It comes with the ability to attach a file via url (user passes in a url to a file) instead of uploading with a form).
It comes with some sort of way to remember files across form validation failures, although I've never used this and I'm not sure how it's done... maybe with two forms and ajax?
It seems to have a more engaged and enthusiastic community around it, with more projects extending it.
For S3, they use fog instead of aws-s3, and fog has much more active development.
That said, paperclip is pretty great and is actively maintained, and might come with handier default image manipulation stuff, I'm not sure.
Related
I need a tiny (less than 100 total) document store in a Rails 3.2 app where a user can create, edit, save, and delete rich text documents (ideally including images and other attached items). There is no file system available. Everthing must go in PostgreSQL database tables. The documents will serve as system-wide email and message banner templates.
My approach has been CKEditor. But the ckeditor gem seems wired for attachments as files. Also, it does not provide create/update storage of the document itself, just attachments.
I know how to roll my own model/controller/view the CKEditor but surely there's a simpler way.
So what is the most direct way to my goal of the rich text document store? Is there a plugin or gem?
More CKEditor references: This thread makes it look like a major project, but it's 2 years old. This one makes it sound like the default, but no other document does.
More
Using S3, Dropbox as suggested are also nogo. As I said, data must reside in PgSQL tables. Good news: found the paperclip_database gem. Bad news: doesn't work seamlessly with the ckeditor gem. The main issue boils out to this bit in the source file database.rb:
def setup_paperclip_files_model
#TODO: This fails when your model is in a namespace.
Indeed it does, as in the Ckeditor::Asset model! Trying a monkey patch now. If anyone has already made these three gems work together correctly, I'll give you the bounty for a pointer!
Pretty sure CKEditor makes it fairly simple to edit database form fields, which is all you'd need for editing the document itself, correct?
As far as attachment storage, you can use paperclip to manage the attachments -- file storage is just the default. If you use paperclip, you can then use one of many storage options from there, such as Amazon S3 storage, Dropbox, or create your own.
Hope that helps.
The first thread you linked to has it correctly: you need to (find or) write a custom server connector, and configure CKEditor to use it. You can find the relevant updated docs here:
http://docs.ckeditor.com/#!/guide/dev_file_browser_api
I like to use heroku and paperclip for image uploads. Usually my users don't need to upload many images.
I'm now embarking on a website where many users will be trying to upload images at the same time. Unfortunately on heroku, it seems I need a separate dyno for every image upload, otherwise the site becomes unresponsive. Or am I missing something?
What is an optimal way to set up a rails application (not necessarily on Heroku) where the site can easily deal with (in a scalable way, ideally) multiple uploads at the same time?
This is a shortcoming with Heroku - it doesn't handle file uploads very efficiently. See this article that discusses this point, among others. The author suggests using the carrierwave_direct gem or the Cloudinary service. Neither concept will work well for Paperclip as it doesn't provide cloud storage support. You might want to move to CarrierWave for easier implementation of these concepts.
I need to be able to encrypt files before storing them on S3, and then decrypt them when accessing them. The files will be images, documents, PDF, etc.
I am using Carrierwave to handle the file upload and storage (this is with Ruby on Rails). I am storing them in Amazon S3.
Has anyone done this, or have any ideas how this would be achieved?
Thanks.
Amazon has now released functionality that lets you encrypt/decrypt files automatically in S3. The need to do this yourself is no longer there. Details are here http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?UsingEncryption.html
To handle the encryption, you should look into implementing a processor. If you are using any other processors, you may have to look at extending the Carrierwave gem and adding a processor ordering mechanism so you can be sure encryption happens last.
For the decryption, you can either override the existing accessor to make the decryption transparent, or add a new method that returns the decrypted file and use that in place of the accessor. The latter approach is probably more resilient to upstream changes.
I know this post is a few months old, but if you're still looking for answers, check out the carrierwave_securefile gem I wrote. It's still new and probably a bit buggy on other setups, but it uses Crypt19 for Blowfish encryption on files prior to upload.
http://github.com/dougc84/carrierwave_securefile
I need to add the ability to upload and store any 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.
I would like users of my ruby on rails app to be able to upload documents (Word Documents, Spreadsheets, PDFs, etc). What is the best way of doing this?
I've used file_column, attachment_fu, and paperclip. I've also had to dive into the source on all three plugins.
Without a doubt, I recommend paperclip above the others. The source is easier to read and understand. Its easier to extend. It doesn't do extraneous file copies.
Go with paperclip and let us know if you have any questions.
"Best" depends on your exact needs, but have a look at PaperClip. It's a pretty easy way to integrate files with ActiveRecord.
I agree that Paperclip is the best solution currently available.
If you decide to use Paperclip, you might want to take a look at this question which discusses how to display thumbnails for non-image types (.doc, .xls etc).
Set path for original images using paperclip in Rails?