Skip to content

qie.addMultipartContentBinary

Signature: qie.addMultipartContentBinary(builder, name, content, contentType*, fileName*, contentDisposition*)

Returns: void

Adds a binary content part to the multipartBuilder object.

Note

This call requires a builder object obtained from a call to qie.getMultipartBuilder().

Note

The optional parameters of contentType and fileName both have to be provided if one is needed. If the contentType is provided, then the fileName is required.

Parameters

Type Name Description Default
multipartBuilder builder multipart builder object
String name part name to add; can be null. Required for Content-Disposition form-data type parts
String, byte[], File, Stream content content to add in part
String contentType* (optional) content type for part application/octet-stream
String fileName* (optional) filename for part null
String contentDisposition* (optional) defines how a part should be presented (e.g., attachment, inline, or form-data, with custom values allowed); attachments require both contentType and fileName parameters, while inline or custom types require the contentType parameter form-data

Examples

Content-Disposition attachment

// Create a multipart builder
// Step 1: Initialize the Multipart Builder
var multipartBuilder = qie.getMultipartBuilder(); // Use the default boundary and mimeType

// Step 2: Add a binary file part
var fileData = qie.base64DecodeToBytes("aGVsbG8="); // Load file as byte array
qie.addMultipartContentBinary(
   multipartBuilder,
   null,                    // Part name (not used for attachment)
   fileData,                // File content as byte array (could also be a string, file, or stream)
   "image/png",             // Content-Type (required for attachment)
   "aang.jpg",              // File name (required for attachment)
   "attachment"             // Make the Content-Disposition attachment, with the filename and content-type
);

// Step 3: Send the multipart entity
var value = qie.callRESTWebService(
     "Vendor API",
     "https://example.com/upload",
     "POST",
     multipartBuilder,
     null, // Use the Content-Type parameter only to specify additional optional attributes (e.g., type or version); the multipart/{mimeType}, and boundary are set automatically by the MultipartBuilder.
     qie.newParameterMap(),
     60000);

Content-Disposition custom

// Create a multipart builder
// Step 1: Initialize the Multipart Builder
var multipartBuilder = qie.getMultipartBuilder(); // Use the default boundary and mimeType

// Step 2: Add a binary file part
var fileData = qie.base64DecodeToBytes("aGVsbG8="); // Load file as byte array
qie.addMultipartContentBinary(
   multipartBuilder,
   null,                    // Part name (not used for custom Content-Disposition)
   fileData,                // File content as byte array (could also be a string, file, or stream)
   "image/png",             // Content-Type (required for custom Content-Disposition)
   null,                    // File name (not used for custom Content-Disposition)
   "alert"                  // Make the Content-Disposition a custom value of 'alert'
);

// Step 3: Send the multipart entity
var value = qie.callRESTWebService(
     "Vendor API",
     "https://example.com/upload",
     "POST",
     multipartBuilder,
     null, // Use the Content-Type parameter only to specify additional optional attributes (e.g., type or version); the multipart/{mimeType}, and boundary are set automatically by the MultipartBuilder.
     qie.newParameterMap(),
     60000);

Content-Disposition inline

// Create a multipart builder
// Step 1: Initialize the Multipart Builder
var multipartBuilder = qie.getMultipartBuilder(); // Use the default boundary and mimeType

// Step 2: Add a binary file part
var fileData = qie.base64DecodeToBytes("aGVsbG8="); // Load file as byte array
qie.addMultipartContentBinary(
   multipartBuilder,
   null,                    // Part name (not used for inline)
   fileData,                // File content as byte array (could also be a string, file, or stream)
   "image/png",             // Content-Type (required for inline)
   null,                    // File name (optional)
   "inline"                 // Make the Content-Disposition inline, with the optional filename and required content-type
);

// Step 3: Send the multipart entity
var value = qie.callRESTWebService(
     "Vendor API",
     "https://example.com/upload",
     "POST",
     multipartBuilder,
     null, // Use the Content-Type parameter only to specify additional optional attributes (e.g., type or version); the multipart/{mimeType}, and boundary are set automatically by the MultipartBuilder.
     qie.newParameterMap(),
     60000);

default

// Create a multipart builder
// Step 1: Initialize the Multipart Builder
var multipartBuilder = qie.getMultipartBuilder(); // Use the default boundary and mimeType

// Step 2: Add a binary file part
var fileData = qie.base64DecodeToBytes("aGVsbG8="); // Load file as byte array
qie.addMultipartContentBinary(
   multipartBuilder,
   "filePart",              // Part name (required for default form-data Content-Disposition)
   fileData,                // File content as byte array (could also be a string, file, or stream)
   "image/png",             // Content-Type (optional for default form-data Content-Disposition)
   "aang.jpg"               // File name (optional for default form-data Content-Dispostion)
);

// Step 3: Send the multipart entity
var value = qie.callRESTWebService(
     "Vendor API",
     "https://example.com/upload",
     "POST",
     multipartBuilder,
     null, // Use the Content-Type parameter only to specify additional optional attributes (e.g., type or version); the multipart/{mimeType}, and boundary are set automatically by the MultipartBuilder.
     qie.newParameterMap(),
     60000);