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-Type
is defined based on the filename extension. If the file extension is not recognized,Content-Type
defaults toapplication/octet-stream
.Note:File extensions to
Content-Type
mapping can be customized in the file $FGLDIR/lib/wse/mime.cfg.Content-Transfer-Encoding
is set to "binary
".Content-Disposition
is 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).