Project Elbow: Files by Name

The SQLManager class was extended to manage a table that maps a logical filename to a cache ID.

The FileLoader class was extended to accept either a FileId or string (filename) in its constructor.

Once FileLoader.load() is called, if the class was instantiated with a filename, then it will search the database for a mapping to an ID.  If there is a mapping, and if the file is still in the cache directory on the PC’s file system, then it will call the service provider and send both the filename and the MD5.

The service provider will either return the file that matches up with that name or return HTTP status 304 if the MD5 matches.

In this way, the application can ask for files by name where the name never changes, but the content returned by the name might.

By the way, it was a bad idea to return an HTTP status of 404 if the ID or filename was not found because this status code really means that the web or application server could not find the requested URI.  It confused Flash’s net stuff…  So, instead I’m returning a JSON structure with a notfound member.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.