com.HTTPPart.CreateAttachment
Creates a new HTTPPart object based on 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 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 file name extension. If the file extension is not recognized,Content-Type
defaults toapplication/octet-stream
.Note: File extensions toContent-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).