A Better way to serve files from the Google App Engine Virtual File System
Web Development, BlueDragon, Google App EngineThe other day I posted an example of how one might access images, for example, from your Google App's virtual file system. While it was sufficient, I wasn't really happy with how the URL's looked and how missing files were managed.
Right as I was writing this post to detail how I had rewritten the url to manage accessing VFS files, Vince posted this to the openBD mailing list...rendering my solution obsolete!
Quoted from the mailing list:
My apologies for taking so long to respond to this thread. In addition to Aaron's "getfile.cfm"--a very nice solution--GaeVFS contains a built-in servlet that allows you to do directory listings and serve files from configured directories. In order to use the GaeVfsServlet, add the following to your web.xml (this example serves files from the "/images" directory of your webapp):<servlet><servlet-name>gaevfs</servlet-name> <servlet-class>com.newatlanta.commons.vfs. provider.gae.GaeVfsServlet</ servlet-class> <init-param><param-name>dirListingAllowed</param-name> <param-value>true</param-value> </init-param><init-param><param-name>initDirs</param-name> <param-value></param-value></init-param></servlet><servlet-mapping><servlet-name>gaevfs</servlet-name> <url-pattern>/images/*</url-pattern> </servlet-mapping>You can then serve files by using normal IMG tags:<img src="/images/mypicture.jpg">You can serve files from as many directories as you'd like by adding multiple <servlet-mapping> elements and specifying the appropriate <url-pattern> elements. Also note the "dirListingAllowed" init parameter which enables/disable directory listings. Further details are available in the javadoc comments in the source code:




Loading....