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
| Name | Type | Description |
|---|---|---|
url | String | The URL to request |
headers | Map? | Request headers. Optional (null). Merged into the default headers (Content-Type: application/json, Accept: application/json) before sending |
fields | Map | Plain text form fields (values are sent as strings) |
files | List | The list of file parts. Each entry is { name, bytes, filename } |
jsCallback | JSFunction? | The callback that receives the response |
Callback
Invoked as jsCallback(statusCode, headers, body).
| Argument | Type | Description |
|---|---|---|
statusCode | number | The response status code |
headers | Map | The response headers |
body | String | The 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);
}
);