multipart
multipart
파일 업로드를 위한 multipart/form-data POST 요청을 전송합니다. files의 각 항목은 { name, bytes, filename } 형태로 하나의 파일 파트를 나타냅니다.
파라미터
| 이름 | 타입 | 설명 |
|---|---|---|
url | String | 요청할 URL |
headers | Map? | 요청 헤더. 생략 가능(null). 기본 헤더(Content-Type: application/json, Accept: application/json)에 병합되어 전송됨 |
fields | Map | 일반 텍스트 폼 필드 (값은 문자열로 전송됨) |
files | List | 파일 파트 목록. 각 항목은 { name, bytes, filename } |
jsCallback | JSFunction? | 응답을 받는 콜백 |
콜백
jsCallback(statusCode, headers, body)로 호출됩니다.
| 인자 | 타입 | 설명 |
|---|---|---|
statusCode | number | 응답 상태 코드 |
headers | Map | 응답 헤더 |
body | String | 응답 본문 |
반환: 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);
}
);