com.HttpPart.CreateAttachment
Creates a new HttpPart object based on a given filename located on disk.
Syntax
CreateAttachment(
filename STRING )
RETURNS com.HttpPart
- filename specifies the name of a file.
Usage
Creates a new HttpPart object based on a given filename located on disk. To be used via the addPart() method.
The
com.HttpPart.CreateAttachment() method automatically sets the following
headers for the created HttpPart object:Content-Typeis defined based on the filename extension. If the file extension is not recognized,Content-Typedefaults toapplication/octet-stream.Note:File extensions to
Content-Typemapping can be customized in the file $FGLDIR/lib/wse/mime.cfg.Content-Transfer-Encodingis set to "binary".Content-Dispositionis set with the base name of the given filename as follows:attachment; filename="basename".
For example, when calling the method as
follows:
LET part = com.HttpPart.CreateAttachment( "/opt/myapp/resources/logo.jpg" )The resulting HTTP part headers will look
like:
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-Disposition: attachment; filename="logo.jpg"In case of error, the method throws an exception and sets the
status variable. Depending on the error, a human-readable description of the
problem is available in the sqlca.sqlerrm register. See Error handling in GWS calls (status).