Storing images not as part of app - ruby-on-rails

I am building my new site and have a small group of images I want to display on the site.
They are not images to do with styling so it feels wrong to store them within the app/assets directory
I don't wish to put them on my Flickr account which builds by apps gallery as they are not that type of image.
I currently have them stored on an Amazon S3 bucket and link to them from there.
is there a better way. What way would you guys choose?
If I am already using the best way, is it worth linking to them using the standard url Amazon provides me with or should I direct one of my URL's to that point?

Your choice for Amazon S3 seems fine to me, and no, you should not change the standard URL's Amazon provides you with. Advantage is that your own web server is not bothered by the image URL's anymore!
I have a similar website storing "dynamic" pictures, and I keep them on cloudinary, which is a similar site. Your source directory should not in general store these "dynamic" pictures. They only consume disk space, and sites like Amazon S3 and Cloudinary are made just for that!

Related

Using cloud storage for images in a Ruby on Rails app

I have been struggling with an efficient way to store and manage the pictures I need in a Ruby on Rails app I am building. I will use a real estate app as an example:
In my real estate app I have a House model and a House controller. On the House #show page I want to list information on the house as well as display pictures for that particular house. Some of the houses have five pictures, others have one. What is the best way to store these pictures and display the ones that pertain to that particular house?
Obviously I do not want to store them with the app, that would be way too bulky. I have tried using Amazon S3 buckets and the Amazon SDK but was unable to get it up and running. Amazon's documentation is all over the place. I currently have pictures stored in a Google Cloud Storage Bucket. They have a public link so an individual image is easy to display. The problem lies in the fact that each house might have a different number of pictures associated with it.
Google's documentation is difficult to navigate, especially when it comes to Ruby. If there were an easy way to access my bucket and filter the files stored there, this would be a breeze. Any ideas? Does anyone know how to do this in Ruby? This type of photo storage is very common and I am surprised at the difficulty I've had in getting it set up. Thanks for your help.
Amazon S3 is one of the best options out there, but it can be a little confusing. Try the paperclip gem for adding file associations to your models.
It gives you multiple options for how to store files and makes it easy.

Is it OK to use Twitter and Facebook profile images without storing them in my server?

Currently I'm using Facebook connect and Twitter oauth to authenticate users. and I'm using their profile image urls directly instead of storing them on my server. I guess it's better to save the thumbnails and think eventually may need to do that, but for now am trying to save as much money as possible. (I'm currently using Heroku to host my project and can't store files unless I use S3 or the likes, which would cost me money)
I'm wondering if this is OK, and if most web apps start out this way. Or if I need to store the images.
Also, now I want to let users set up accounts without Twitter or Facebook. In this case, is there a way to use a "third party thumbnail hosting site" (I don't even know if such a thing exists) for free instead of using S3? It can even be a short term hack, since I plan to eventually implement image storage if this gets traction.
I think not storing them is the best way. If someone changes their picture, you always show the latest this way, if you stored them, well then you would have an old version of their picture after time which could make your app look stale.
As for where to store alternatives, I would really consider s3. It is very cheap storage, and thumbnails won't need a lot of space. It would only get expensive if you had a LOT of users, and if you have a LOT of users, you should be able to afford the storage.
Also, have you looked at Gravatar? A lot of people have those linked to their email addresses, it might be another good way to get their picture. http://en.gravatar.com/site/implement/

rebranding rails application

I would like to rebrand my Rails app so that each user will have their own configuration like CSS, logos etc. We are storing the logos and fav icons in Amazon S3. Please let me know what is the best way to retrieve as if i retrieve from their for every request that will cost me lot of bandwidth because every page will have logo and the fav icon. I am looking for a most economic way of storing those images.
You could download the logos running wget within RoR, telling the application to store it on a special folder.
But, the best way to save bandwidth would be directly linking the logos and favicons that are in Amazon S3.

Storing images for multiple web sites

I've got two web sites (written in c#) which are pretty common:
One is an admin site (cms) where you add images into content as needed, through editor pages.
Second is the site where the content with images is shown.
Images should be stored outside these two sites but where and how?
You could store them on a third site for static content, then both sites would link to that content. That can give you some benefits if you really need scalability as well.
However, you may also store it in a shared database, or just a shared file share, that you have encapsulated logic that each sites that needs access to them uses.
If you dont want to both with the storage there are many "cloud" storage servers that will host all your images for you. (like Amazon S3, Smugmug, flickr).
But then you will have to build the logic in your app to upload the submitted images to your 3rd party storage provider.
You can store images inside a database. There are plenty of tutorials on how to store images in a database (images in mysql php, images in mysql asp.net, etc). The language isn't important, any of the tutorials can help show how to store images inside the database itself. Then it's just a matter of language specific calling the image out to display it.
Have you considered storing your images on something like Amazon S3? You could then access the images from both sites. Somehow, though, you'll need to store the URLs to the images and make them available for both sites.
If both sites run off of the same database, this is fairly easy, however, if they are separate databases, then I would suggest creating some sort of API on the creation site so that the content site can easily discover which images are available to be shown.

Anyone know of a simple way to store the Rails Page cache on Amazon S3?

I am looking for a simple and automated way to store the page cache on S3 (and of course cloudfront.) I know of a plugin that does this with the fragment cache, but before I create it myself, wanted to tap into the collective wisdom here :)
Edited: To make myself more clear, I am not looking to use S3 to serve the files, but rather, the CloudFront CDN.
In order to put something in CloudFront, you have to first have it in S3. See Amazon's introduction for all the steps. Basically, you put the document in a bucket on S3 and then make an API call to register your bucket for distribution (you do this using a perl script they provide). At that point, they transfer the contents of your bucket out to the edge servers for high performance distribution. You can change the contents of your bucket once an hour.
Anyway, in order to use CloudFront, what you really need to do is get the contents of your rendered pages into S3. Once you've gotten your distribution up and running this is how you manage your content in CloudFront.
The simplest way to manage a cache in S3 would probably be to create a model for your cache and use the attachment_fu plugin to store the page contents in s3. Then, you could use ActiveRecord's Observer functionality to invalidate and re-populate the cache as appropriate for your application. The only other tricky bit would be reaching into ActionView to access the result of rendering a page, but I bet you could crib some of that code from the default page caching system itself.
If you really wanted to, you could probably wrap all of this functionality up into a plugin that would make it easy to re-use across applications for you and others.
I read the headline and was going to tell you Amazon started doing a CDN a few weeks back. But obviously, you already know that. :)
There's a Python package that looks like it wraps CloudFront, botto. But that's all I can find.
I think you're the first... go forth and start it. Let me know where it is, I'll probably fork it.

Resources