开发者

What is an easy way to upload an image into a database in rails on heroku?

I have an application which has the requirement, but infrequent usage, of uploading an image for use in other parts of the application. It's not something that is done frequently, nor is it frequently viewed (such as a photo). It is an image which is then sent through an API to print and deliver as a postcard.

Initially I used paperclip and loved how easy it was to attach the image to the Model. But on heroku I would need to then set it up to work with S3, which could be fine, but I've been thinking that perhaps it should just be in the database.

I need to upload it as a binary through the API each time I sent it as a postcard.

Wh开发者_StackOverflowat would be the recommended way to do this? Is there a plugin or gem that would make it easier? Is uploading to the database as a blog a more straightforward way?


paperclip is pretty easy to setup and a buddy of mine has a site that he just did with a fair number of images uploaded from it, and his total S3 bill from amazon last month was 10 cents. SO I wouldn't shy away from it because of cost. I just added the paperclip folder from one of my apps to S3 to scope what it would cost. I can report back in a week or so when I get my first bill.


If you end up going the route of uploading directly to S3 which offloads the work from your Rails server (and doesn't store it in the Heroku database), please check out my sample projects:

Sample project using Rails 3, Flash and MooTools-based FancyUploader to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-FancyUploader

Sample project using Rails 3, Flash/Silverlight/GoogleGears/BrowserPlus and jQuery-based Plupload to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-Plupload

By the way, you can do post-processing with Paperclip using something like this blog post describes:

http://www.railstoolkit.com/posts/fancyupload-amazon-s3-uploader-with-paperclip

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜