|
Developing a Whitebeam Application
|
FilesTwo types of file access are supported within the Whitebeam system,
the File template provides for file storage and retrieval within the database
and the special method calls provide read-only access to the web server file
system. The File template provides facilities to read and write files
up to 100K bytes in size together with associated information such as a name
and description. This template is available in its own right and also other
templates make use of the file template, for example to hold images of products
stored as items within the Catalogue template. A special Binary JavaScript object
type is provided by the Presentation Engine to enable the files to be manipulated
programmatically. For example the following code loads a file form variable
into a local Binary object: var parameters = rb.page.formdata();
var binaryFile = parameters.file0;
The Binary object has some methods defined for it such as mime()
which sets or reads the mime type of the file (note that the File template stores
Binary objects so implicitly holds the mime type of the file being manipulated). rb.page.write(binaryFile.mime());
The load() method of the binary object lets
you load up a file from the file system into the object. Typical uses for this
could be to secure the download of, say, a "pdf" document. By wrapping
the access to the document in an authenticated Pattern Page direct access is
prevented. See the widgets section of the
sample applications for an example of how to do this. |
|
(loadtime : 8ms) |