14.1 Online Photo Album

Now let's examine how we would implement a hypothetical Web service using WebDAV. As digital cameras have become more popular, a number of Web sites have emerged to allow people to share, manage, and print their digital images. These services are generally called online photo albums.

14.1.1 Application Overview

An online Web-based photo album is a Web service that hosts collections of photos for many users. The service provider can offer the service for free, support it via advertisements, or charge for this service. The site could contain mostly people's travel and family pictures, professional photographers' portfolios, or images collected by a publisher for use in books. We'll assume that the users are regular computer users with no special software-related expertise, so the service has to be easy to use.

Images can be created in many applications. Digital photos can be created directly on the user's computer from a connected camera, downloaded from a portable camera, or scanned in. Applications like Adobe Photoshop are used to create enhanced photos. Most likely, the image is stored at some point on the user's computer (see Figure 14-1).

Figure 14-1. Photo-sharing life cycle.

graphics/14fig01.gif

Uploading files is a special-case function on the Web. Browsers must protect users' privacy. In the upload case, this means ensuring that unauthorized Web sites cannot select and upload users' files from their hard drives. Consequently, Web browsers have security blocks built in specifically so that when the server suggests a file upload (through an HTML form), the user must be involved to select a single file and agree to upload it.

Frequently users have several images to upload at the same time. It is possible to use an HTML form to upload multiple files, but it's not exactly easy to use. Only one file can be selected for each file upload input slot. To upload five files, the user must select each file independently in its own input slot and then submit the HTML form (or worse, submit the HTML form five times). It's not possible with ordinary HTTP Web browsers to upload five files by selecting them all together.

To solve the multiple-file upload problem, Shutterfly (a public Web photo album service) implemented a special plug-in for Web browsers. This plug-in is very nice, but not only did Shutterfly have to develop it and maintain it, but each user had to agree to terms of use and download and install this component.

Once images are uploaded to the server, they may be arranged according to how or when the pictures were taken, the subject matter, or some other scheme. In any case, users must be able to organize images according to their own plan. It would be nice if it were possible to reorganize images too, to be able to move them from one collection to another.

Once the images are uploaded, other users can view the images. In most public Web photo services, anybody can view the images, so security is rather minimal. For example, a photo collection may have a password, which every viewer needs to know. Another possibility (as in Shutterfly) is that the album may only be viewable by users who have an account with the Web service. Note that the user must be able to set permissions at the granularity of an album at least, if not on individual pictures.

When sharing photos, users like to give their images names and comments. Some systems might allow more detailed information, such as who took the picture and when it was taken. In addition, the photo albums or collections of photos need to be named.

14.1.2 Existing Architecture

An online photo album service can be implemented using only a Web server with an extensibility model (e.g., Apache with CGI scripts). However, the result would be rather hard to implement, be difficult to use, and perform poorly. We can reconstruct how a theoretical Web-based photo album service would be implemented, and consider the challenges:

  • The implementation would take a lot of time because every function has to be implemented from scratch. For example, Web servers don't have native ways to allow the client to move a Web resource (like an image) from one place to another, so the Web service has to be programmed to do that.

  • The Web user interface would be difficult to use, particularly for uploading multiple photos, but also for moving, renaming, and deleting photos. Users may be accustomed to using a tool like Windows Explorer to move, rename, and delete files, but they can't use these skills with a plain Web interface, because the interface features aren't rich enough.

  • The service would perform poorly because all the work of collating data and preparing the presentation must be done on the server. The server is the bottleneck for all client access tasks, and because the server does all the heavy lifting, this becomes a very narrow bottleneck indeed.

Figure 14-2 shows a simple Web service architecture that could be used to run a photo album service or many other kinds of data-backed Web service. This architecture is characterized by a completely server-controlled and server-processed presentation layer on the front end and a tight dependency on the data schema on the back end.

Figure 14-2. Simple Web service architecture.

graphics/14fig02.jpg

14.1.3 WebDAV for Photo Authoring

How can WebDAV help in this scenario? What if users could:

  • Use a familiar interface, like Explorer, to upload several photos at once?

  • Use a familiar interface to move, copy, rename, and delete photos on their collections on the server?

  • Use Photoshop or any image-processing application to edit photos from the server and save the photos directly back to the server?

WebDAV offers these features by making photos available as WebDAV resources organized in WebDAV collections. Web Folders and Photoshop natively support the WebDAV protocol and can store files directly on a WebDAV repository. Editing documents directly on a Web repository (without having to download, edit, and upload as three separate steps) is a unique feature of WebDAV and is extremely difficult to provide through HTTP alone.

A photo album service could easily be based on WebDAV from the ground up. This architecture has additional benefits that end users aren't aware of, but these benefits would be important to an Internet startup on a shoestring budget:

  • New WebDAV tools are automatically supported. For example, if camera software had WebDAV functionality added, users could save to the Web service right from their camera. Less development is required.

  • The server-side presentation layer can be easily separated from the data layer. More data is served directly from the data layer, with less presentation processing required by the server. Fewer servers are required.

  • The data layer automatically handles a rich permission model. The Web service implementors can use as much or as little of this model as desired. Permissions are guaranteed to be consistent.

  • It is trivial to make the service richer by adding features based on properties. For example, a "style" property (baby album, wedding album, trip album) could be added to each collection simply by using a new WebDAV property. Costly data re-architecture (such as database schema modification) is unnecessary; the programmers can focus on the features.

  • It is trivial to extend the service by allowing multiple people to share authoring responsibility for a photo album. With WebDAV locks and permissions, this feature works properly.

  • Performance improves because the most frequent type of request (a simple download of a single photo through a GET request) is handled by commercial software that has been tuned to do this quickly.

How Properties Are Exposed

When a Web application uses WebDAV properties, standard Web browser software can't automatically view those properties. Some code is still required to pull the property values into a Web page, format, and display them. Today this is most commonly server-side code such as JSP or ASP pages. However, there are higher-performance alternatives in which the processing and presentation is offloaded to the client, as discussed in Section 14.2.4.


This model assumes that the application is designed with WebDAV in mind, such that WebDAV can be the primary storage model for all the information stored through the Web service. This requires some familiarity with the WebDAV data model to choose how to represent application data most effectively (see Figure 14-3).

Figure 14-3. WebDAV as primary storage model.

graphics/14fig03.jpg

WebDAV is an appropriate technology to use for this purpose, because photos can be simple WebDAV resources and photo albums can be WebDAV collections. Any additional information can be associated with either an individual photo or a collection, using WebDAV properties.

14.1.4 Gateway Model

If the photo album service has already been deployed without WebDAV support, is it worthwhile transitioning to WebDAV? A full transition can be difficult and time consuming. Another model is to expose the existing service through a WebDAV gateway. This could provide the end user benefits of WebDAV access to photos and albums without having to rewrite core architecture.

A WebDAV gateway would not likely be an out-of-the-box solution in this case, but that doesn't mean that the Web service implementors would have to do all the work. For example, the mod_dav module can plug into a custom data layer using a simple data access interface (see Figure 14-4).

Figure 14-4. WebDAV gateway with existing data storage.

graphics/14fig04.jpg

14.1.5 Lessons Learned

Why does WebDAV provide such convenience and benefits for a photo album service? To generalize this example, it's useful to see what characteristics made the photo album application so easy to map to WebDAV. Conversely, some of these lessons point out the WebDAV characteristics that make it so useful in this situation.

A Web-Based Service

The Photo Album service was conceived as a Web service from the start. WebDAV extends HTTP, so it fits well into this model. Rather than route every JPEG and GIF through the custom code of the Web service, browser requests for photos can be handled directly by the WebDAV repository. The custom code in the Web service can focus on the presentation of thumbnails, browsing albums, and showing banner advertisements all the value-added functionality, that is, rather than the basics.

Authoring Applications Natively Supported

Photos are authored as well as simply uploaded and viewed. End users benefit from being able to use authoring applications (Photoshop, PowerPoint, Illustrator) to directly access files on the server. A photo stored on the server can be touched up with Photoshop quite simply: The user opens the photo, makes changes, and saves it back to the server.

Flexible Metadata Support

Photos and albums require metadata to be coordinated into a rich Web presentation. Since a WebDAV repository must already support metadata, the photo album service implementors don't have to do a lot of work to add properties to photos. Even better, there's no fixed schema for properties, so the implementors can add functionality as they go along. That's much easier than knowing the schema, field names, and data types at the beginning of the project. These properties can be static (defined when the photo is updated), calculated live by the server, or even created by the end user.

Document-Oriented Storage

The Photo Album service naturally conforms to storing documents in folders. It works much better when using WebDAV to handle this document storage than when using a database, where storage of large "blobs" is not always easy (photos can be several megabytes in size). Even if the Photo Album service were architected to use regular Web server file storage for the photos and use a database only for storing metadata, the database is inferior for this purpose because the metadata has to be associated with each photo using custom code. Using a WebDAV server means that metadata is already associated with each photo, so that whenever a photo is moved or copied, its metadata goes with it.

Native Support for Document Management

For the online Photo Album service, the simple document management features WebDAV provides (moving, locking, synchronizing) are quite useful. WebDAV provides a way for users to organize and upload their photos without requiring custom code on the part of the service providers. Savvy users can use a tool like sitecopy to keep their online photo album synchronized with a local copy of all the photos.



WebDAV. Next Generation Collaborative Web Authoring
WebDAV. Next Generation Collaborative Web Authoring
ISBN: 130652083
EAN: N/A
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net