I'm working on implementing a "virtual file system" for the Google App
Engine (GAE). My primary goal is to be able to support <CFFILE
ACTION="UPLOAD"> but of course supporting file uploads isn't very
useful unless you can later access the file via <CFFILE ACTION="READ">
or <CFCONTENT>. Supporting the FileExists() function would also be
useful.

I'd like to solicit some opinions regarding implementation. The tricky
part is that GAE lets you read from, but not write to the real
(physical) file system. Therefore, while <CFFILE ACTION="UPLOAD"> and
<CFFILE ACTION="WRITE"> can only write to the "virtual" file system,
<CFFILE ACTION="READ"> and <CFCONTENT> could read from either the real
file system or the virtual file system. For the latter two tags, I've
thought of some possible implementations:

 1) First try to read the real file system, and if the file isn't
found, then try to read the virtual file system. For the virtual file
system, the FILE attribute would just be used as a key to locate the
file within the GAE datastore (that is, I'm not going to try to
emulate a hierarchical file system).

 2) Use some sort of virtual file system indicator in the FILE
attribute to indicate that the GAE virtual file system is to be used.
For example: <CFFILE ACTION="READBINARY" FILE="~google/mypicture.jpg"
VARIABLE="imageVar">

 3) Add a new attribute to indicate that the GAE virtual file system
should be used. For example: <CFFILE ACTION="READBINARY"
FILE="mypicture.jpg" FILESYSTEM="google" VARIABLE="imageVar">

A benefit of solution #1 is that it's the most transparent (it "hides"
the virtual file system) and will make it easier to port existing
applications to GAE. For example, I'm porting BlogCFC and it wants to
use the "enclosure" directory for uploading files; solution #1 might
allow me to port BlogCFC without modifying it at all, where solutions
#2 or #3 would require some BlogCFC code modifications (probably by
making the location of the "enclosure" directory configurable).
Another benefit of #1 is that it would allow you to transparently
treat the virtual file system as an extension to the real file system.
For example, I could create an "images" directory on the real file
system, and then upload files to the "images" directory in the virtual
file system, and then use <CFFILE ACTION="READBINARY" FILE="/images/
#imageFileName#"> to read images regardless of which file system they
were stored in.

A disadvantage to #1 is that it could be more complicated, and the
transparency of the virtual file system is potentially confusing. For
example, in the case of an "images" directory as desribed above, what
happens when there are file name conflicts? Does the OpenBD code try
to manage things so conflicts don't happen, or is that up to the CFML
coder? Another disadvantage to #1 is that it doesn't allow the CFML
coder to explicitly say, "I want this file to be read from the virtual
file system." Neither of these disadvantages exist in solutions #2 and
#3.

Another thing to consider is the CFDIRECTORY tag. How should we modify
the CFDIRECTORY tag to allow a listing of all files in the virtual
file system? If we choose solutions #2 or #3, the answer is
straightfoward, either specify <CFDIRECTORY ACTION="list"
DIRECTORY="~google"> or <CFDIRECTORY ACTION="list"
FILESYSTEM="google"> but what about solution #1? The whole point of
solution #1 is to be transparent, but you lose that transparency if
you modify the CFDIRECTORY tag to explicitly "know" about the GAE
virtual file system.

Finally, another point to consider is that if might also be useful to
provide URL mapping to the virtual file system so that content could
be served from there directly without having to resort to CFCONTENT.
For example, imagine that you could create a mapping from "/images" to
"~google/images" and then upload files into the "~google/images"
virtual file system? Then any incoming URLs for "/images" would get
served directly from the virtual file system. (I'm not sure if or how
this affects the choice of solutions #1, #2, or #3, but thought I'd
throw it out there).

Any thoughts or feedback is welcomed. I've basically got <CFFILE
ACTION="UPLOAD"> working, and am "stuck" trying to make this
implementation decision. The decision pretty much boils down to: Do we
want access to the GAE virtual file system transparent (#1) or
explicit (#2 or #3)?
--~--~---------~--~----~------------~-------~--~----~
Open BlueDragon Public Mailing List
 http://groups.google.com/group/openbd?hl=en
 official site @ http://www.openbluedragon.org/

!! save a network - trim replies before posting !!
-~----------~----~----~----~------~----~------~--~---

Reply via email to