Builds a multipart form body for use with XMLHttpRequest.send(), mirroring the browser FormData API for app scripts that need to post multipart/form-data content. Values can be appended as plain strings, byte arrays, input streams, uploaded file items, or Kademi content resources, each becoming its own named part. An instance is constructed with a plain 'new FormData()' from script code, populated with append(), and then passed to XMLHttpRequest.send() to populate the outgoing request body.


Methods

append(String name, String value) · append(String name, InputStream in) · append(String name, InputStream in, String fileName) · append(String name, FileItem fileItem) · append(String name, FileItem fileItem, String fileName) · append(String name, AbstractContentResource acr) · append(String name, AbstractContentResource fr, String fileName) · append(String name, FileNode fileNode) · append(String name, FileNode fileNode, String fileName) · append(String name, byte[] bytes) · append(String name, byte[] bytes, String fileName) · delete(String name) · has(String name)

append(String name, String value)

Returns: void

Appends a plain text part to the form body under the given field name. Multiple values can be appended under the same name; each becomes a separate part.

ParameterDescription
namethe field name of the part
valuethe text value of the part

append(String name, InputStream in)

Returns: void

Appends the full contents of a stream as a part with no file name, reading it into memory. Equivalent to calling append(name, in, null).

ParameterDescription
namethe field name of the part
inthe stream to read the part content from; it is read fully but not closed

append(String name, InputStream in, String fileName)

Returns: void

Appends the full contents of a stream as a file part, reading it into memory and deriving the content type from the given file name.

ParameterDescription
namethe field name of the part
inthe stream to read the part content from; it is read fully but not closed
fileNamethe file name recorded on the part, used to work out its content type

append(String name, FileItem fileItem)

Returns: void

Appends an uploaded file item as a part, using its own content type and file name.

ParameterDescription
namethe field name of the part
fileItemthe uploaded file item to read the part content, content type and file name from

append(String name, FileItem fileItem, String fileName)

Returns: void

Appends an uploaded file item as a part, using its own content type but overriding the file name recorded on the part.

ParameterDescription
namethe field name of the part
fileItemthe uploaded file item to read the part content and content type from
fileNamethe file name to record on the part, in place of the file item's own name

append(String name, AbstractContentResource acr)

Returns: void

Appends a Kademi content resource as a file part, using its own name as the part's file name. Equivalent to calling append(name, acr, acr.getName()).

ParameterDescription
namethe field name of the part
acrthe content resource whose content is sent and whose name is used as the file name

append(String name, AbstractContentResource fr, String fileName)

Returns: void

Appends a Kademi content resource as a file part, overriding the file name recorded on the part. The resource's content is read fully into memory before being added.

ParameterDescription
namethe field name of the part
frthe content resource whose content is sent
fileNamethe file name to record on the part

append(String name, FileNode fileNode)

Returns: void

Appends a VFS file node as a file part, using its own name as the part's file name. Equivalent to calling append(name, fileNode, fileNode.getName()).

ParameterDescription
namethe field name of the part
fileNodethe file node whose content is sent and whose name is used as the file name

append(String name, FileNode fileNode, String fileName)

Returns: void

Appends a VFS file node as a file part, overriding the file name recorded on the part.

ParameterDescription
namethe field name of the part
fileNodethe file node whose content is sent
fileNamethe file name to record on the part

append(String name, byte[] bytes)

Returns: void

Appends a raw byte array as a part with no file name. Equivalent to calling append(name, bytes, null).

ParameterDescription
namethe field name of the part
bytesthe raw content of the part

append(String name, byte[] bytes, String fileName)

Returns: void

Appends a raw byte array as a part, working out its content type from the given file name when one is supplied. This is the method every other append() overload ultimately delegates to.

ParameterDescription
namethe field name of the part
bytesthe raw content of the part
fileNamethe file name recorded on the part and used to derive its content type, or null for a plain text part with no content type

delete(String name)

Returns: void

Removes all parts previously appended under the given field name, if any exist.

ParameterDescription
namethe field name to remove

has(String name)

Returns: boolean

Checks whether at least one part has been appended under the given field name.

ParameterDescription
namethe field name to check
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.