Holds key-value pairs and file attachments for encoding multipart HTTP request bodies.
Example
// FormData builds multipart HTTP request bodies. // Create an instance, then append string or binary parts with headers. const { FormData, HttpRequest } = awaitimport('LensStudio:Network');
constform = newFormData();
// Append a plain-text field form.append('field=hello', { 'Content-Disposition':'form-data; name="greeting"' }); console.log('Appended text part to FormData');
// Append a binary payload constbinaryData = newUint8Array([0x89, 0x50, 0x4e, 0x47]); form.append(binaryData, { 'Content-Disposition':'form-data; name="file"; filename="image.png"', 'Content-Type':'image/png' }); console.log('Appended binary part to FormData');
// Use the FormData as the body of an HttpRequest constrequest = newHttpRequest(); request.url = 'https://httpbin.org/post'; request.method = HttpRequest.Method.Post; request.body = form; console.log('Created HttpRequest with FormData body, method:', request.method);
Holds key-value pairs and file attachments for encoding multipart HTTP request bodies.
Example