Technologies and platforms used

We use a number of technologies in this chapter, mainly revolving around the Ruby programming language and its various libraries. In addition to Ruby and its libraries we also use a few mashups, which are described below. For more information on the technology stack used in this book (and in this chapter) please refer to Chapter 1.

Mashups

As with previous chapters, while the main features in the applications are all implemented within the chapters itself, sometimes we still depend on other services provided by other providers. In this chapter we use three services—RPX for user web authentication, Gravatar for avatar services, Amazon S3 for photo storage, and Pixlr for photo editing.

RPX

RPX is an authentication provisioning service provided by JanRain, a technology startup with deep roots in the OpenID community. It doesn't do the actual authentication itself but acts as a proxy to a multitude of third party authentication providers such as Google, Yahoo!, MySpace, Windows Live ID, Facebook, and Twitter, and a number of OpenID providers such as LiveJournal and Blogger. By wrapping around these third party providers it exposes a uniform interface that enables web sites and applications to easily use any of the third party authentication providers. RPX was previously discussed in more detail in Chapter 3.

Gravatar

Gravatar is short for Globally Recognized Avatar, and is a free Internet application that allows you to map avatars (which are mid to small-sized thumbnail pictures representing yourself) to e-mails. The service itself is quite simple—it allows the user to add any number of avatar pictures and also any number of e-mail addresses that belong to you. You can map any of the pictures to any of the e-mail addresses. We discussed Gravatar previously in Chapter 3.

Pixlr

Pixlr is one of many pieces of free online photo-editing software available on the Internet. Amongst its other more prominent competitors are FotoFlexer and Picnik. We chose Pixlr for Photoclone for a few reasons, including its neat look and feel, but mainly because other online photo editing software embeds advertising when used.

Pixlr has two photo editors—Pixlr Editor and Pixlr Express. Pixlr Editor is more sophisticated and complex, while Pixlr Express offers a simple way to edit photos. In Photoclone we will use Pixlr Express.

Pixlr has a small but effective set of APIs and it can be used in a few ways. Pixlr APIs can be used in many ways, including through HTTP GET and HTTP POST forms. However, for Photoclone we are going to use the Pixlr Javascript library.

The Javascript library allows us to call Pixlr in a few ways:

  • As an overlay on top of the current page
  • Opening up Pixlr in the same window
  • Opening up Pixlr in another window

In Photoclone we will use the Javascript library to open Pixlr Express in the same window.

Amazon Web Services Simple Storage Service (S3)

Amazon.com is a successful Internet retailer that started from selling books through the Internet but has since extended its business to selling electronics, CDs, DVDs, and many other types of merchandise. In July 2002, Amazon.com launched the Amazon Web Services (AWS), a collection of web-based computing services. The AWS provided these services over the Internet, through HTTP, either REST or SOAP based interfaces. The services were billed per usage via various means, with a rather complicated billing calculation. AWS's revolutionary services were the pioneers of what eventually fell under the general umbrella of cloud computing.

One of the earliest services that were provided by AWS was the Simple Storage Service (S3). The AWS S3 was the first publicly available web service, first launched in 2006 in the U.S. and rolled out subsequently to Europe in 2007 and Asia/Singapore in 2010. Its basic premise is to provide unlimited storage space through a simple web service, charged per usage. The AWS S3 was built for scalability and high availability. Amazon claims to have more than 64 billion objects stored in its S3 servers as of August 2009.

AWS S3 allows users to store objects up to 5 GB in size, each accompanied by up to 2 KB of metadata. Objects are organized into buckets and identified within each bucket by a unique, user-assigned key. Buckets are organized within S3 to be unique although bucket names can be arbitrarily assigned by the user. A bucket can be stored in one of several regions including the U.S. Standard (Northern Virginia), EU (Ireland), the U.S-West (Northern California), and Singapore. Objects stored in a particular region never leave the region unless they are transferred out. Amazon provides authentication mechanisms—objects can be made private or public, and rights can be granted to specific users.

Buckets and objects can be created, listed, and retrieved using either a REST-style HTTP interface or a SOAP interface. Objects can be downloaded using various protocols including HTTP GET and Bittorrent.

Bucket names and keys (that identify objects that are stored) are chosen so that objects are addressable using HTTP URLs:

Before we can start using the AWS S3, we will need to register for an Amazon account at htttp://aws.amazon.com and then sign up for the S3 services at http://aws.amazon.com/s3. Each service is signed up individually so do not expect to sign up for all AWS services in one go. After you have signed up for AWS S3 services, you can go into your credentials and look for your access key and secret keys. You will need these to connect to AWS S3.

Amazon Web Services Simple Storage Service (S3)

While using the AWS S3 can be quite involved, in Photoclone we will be using a Ruby gem called RightAWS to shield us from the mundane complexities and focus on just storing Photo objects in AWS S3.

RightAWS

RightAWS is a set of Ruby libraries used to access AWS, packaged in a gem and provided by RightScale, a company that provides cloud computing management services. RightScale has a fully automated management platform used to control and manage cloud services and is one of the more prominent companies providing services in this new domain. RightAWS provides access to more than AWS S3 but in Photoclone we only use the S3 interfaces.

Installing RightAWS is very simple:

$ gem install right_aws

For Photoclone we will only use its S3 interfaces and concentrate on using RightAws::S3Interface. To setup RightAWS services we need to provide the access key and secret keys that you got from the security credentials in AWS. In Photoclone we set up a constant with the connection to the RightAWS::S3Interface:

S3 = RightAws::S3Interface.new(S3_CONFIG['AWS_ACCESS_KEY'], S3_CONFIG['AWS_SECRET_KEY'], {:multi_thread => true, :protocol => 'http', :port => 80} )

Note that we are setting RightAWS to be multi-threaded because Photoclone is a web application and more than one user might be uploading or downloading photos at the same time; if it is single-threaded we won't get very far.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.22.164