Skip to main content

multipart

multipart

Sends a multipart/form-data POST request for uploading files. Each entry in files takes the form { name, bytes, filename } and represents one file part.

Parameters

NameTypeDescription
urlStringThe URL to request
headersMap?Request headers. Optional (null). Merged into the default headers (Content-Type: application/json, Accept: application/json) before sending
fieldsMapPlain text form fields (values are sent as strings)
filesListThe list of file parts. Each entry is { name, bytes, filename }
jsCallbackJSFunction?The callback that receives the response

Callback

Invoked as jsCallback(statusCode, headers, body).

ArgumentTypeDescription
statusCodenumberThe response status code
headersMapThe response headers
bodyStringThe response body

Returns: void

Example

$http.multipart(
"https://api.example.com/upload",
{},
{ title: "report" },
[{ name: "file", bytes: fileBytes, filename: "report.pdf" }],
function (status, headers, body) {
$log.d(status, body);
}
);