User's Manual

30 Chapter 3
rmdir()
Removes the specified directory and returns true if the directory could be removed and
false if it could not.
Syntax
var success = <object name>.rmdir(
<"recurse">
);
Parameters
recurse - controls whether the contents of the specified directory are deleted. If this is set
to true, the directory and all of its content is removed. If set to false, the directory is only
deleted if it is empty.
write()
Writes a string to the end of the file.
Syntax
<object name>.write(
<"string">
);
Parameters
string - specifies the string to write. The string must be in quotes.
Global Request and Response Objects
For every request, MediaScript creates a global HTTPRequest object named “req” and a
global HTTPResponse object named “resp”. You can use the request object to get request
parameters, HTTP headers, and information about the MRL. The request object interface is
described in detail in the HTTPRequest reference section. You can use the response object
to set the response contents, HTTP response headers, and status code. See “HTTP
Response Methods” on page 36 for more details.
Setting the Response Contents
There are several ways to set the response contents. The simplest is to use the Media
object's save() method without a name parameter. For example:
img.save(type @ "jpeg");
When the script terminates, the contents of the img object are saved to the cache so that
subsequent requests can be returned immediately without having to re-execute the script.
The response contents can also be set explicitly using the response object's setObject()
method. For example, the previous example could be rewritten as:
resp.setObject(img, RespType.Cached, {type: "jpeg"});