이미지 파일
메시지 발송에 필요한 이미지 파일을 관리 합니다.
이미지 파일 사전 등록 후 이미지 메시지(MMS, RCS, 친구톡)를 전송 할 수 있습니다.
등록된 이미지 파일은 발급 된 파일키 또는 이미지 URL로 유효기간까지 재사용 할 수 있습니다.
서비스 타입별 지원하는 이미지 파일 종류는 여기를 참고해 주십시오.
등록하는 이미지 파일명은 최대 40자 까지이며 영문,숫자를 권장합니다.
multipart/form-data 형태로 요청합니다.
curl -X POST https://omni.ibapi.kr/v1/file/MMS \
-H "Accept: application/json" \
-H "Authorization:Bearer 발급받은 토큰" \
-F file=@파일경로/파일명.jpg
import java.io.*;
import okhttp3.*;
public class Main {
public static void main(String []args) throws IOException{
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("file","/C:/1.jpg",
RequestBody.create(MediaType.parse("image/jpeg"),
new File("/C:/1.jpg")))
.build();
Request request = new Request.Builder()
.url("https://omni.ibapi.kr/v1/file/MMS")
.method("POST", body)
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer 발급받은 토큰")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}
package main
import (
"fmt"
"bytes"
"mime/multipart"
"os"
"path/filepath"
"io"
"net/http"
"io/ioutil"
)
func main() {
url := "https://omni.ibapi.kr/v1/file/MMS"
method := "POST"
payload := &bytes.Buffer{}
writer := multipart.NewWriter(payload)
file, errFile1 := os.Open("/C:/1.jpg")
defer file.Close()
part1,
errFile1 := writer.CreateFormFile("file",filepath.Base("/C:/1.jpg"))
_, errFile1 = io.Copy(part1, file)
if errFile1 != nil {
fmt.Println(errFile1)
return
}
err := writer.Close()
if err != nil {
fmt.Println(err)
return
}
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer 발급받은 토큰")
req.Header.Set("Content-Type", writer.FormDataContentType())
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://omni.ibapi.kr/v1/file/MMS',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('file'=> new CURLFILE('/C:/1.jpg')),
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Bearer 발급받은 토큰'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var fs = require('fs');
var options = {
'method': 'POST',
'url': 'https://omni.ibapi.kr/v1/file/MMS',
'headers': {
'Accept': 'application/json',
'Authorization': 'Bearer 발급받은 토큰'
},
formData: {
'file': {
'value': fs.createReadStream('/C:/1.jpg'),
'options': {
'filename': '/C:/1.jpg',
'contentType': null
}
}
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://omni.ibapi.kr/v1/file/MMS");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer 발급받은 토큰");
var content = new MultipartFormDataContent();
content.Add(new StreamContent(File.OpenRead("/C:/1.jpg")), "file", "/C:/1.jpg");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Authorization", "Bearer 발급받은 토큰");
var formdata = new FormData();
formdata.append("file", fileInput.files[0], "/C:/1.jpg");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: formdata,
redirect: 'follow'
};
fetch("https://omni.ibapi.kr/v1/file/MMS", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import http.client
import mimetypes
from codecs import encode
conn = http.client.HTTPSConnection("omni.ibapi.kr")
dataList = []
boundary = 'wL36Yn8afVp8Ag7AmP8qZ0SA4n1v9T'
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=file; filename={0}'.format('/C:/1.jpg')))
fileType = mimetypes.guess_type('/C:/1.jpg')[0] or 'image/jpeg'
dataList.append(encode('Content-Type: {}'.format(fileType)))
dataList.append(encode(''))
with open('/C:/1.jpg', 'rb') as f:
dataList.append(f.read())
dataList.append(encode('--'+boundary+'--'))
dataList.append(encode(''))
body = b'\r\n'.join(dataList)
payload = body
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer 발급받은 토큰',
'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("POST", "/v1/file/MMS", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"
url = URI("https://omni.ibapi.kr/v1/file/MMS")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Bearer 발급받은 토큰"
form_data = [['file', File.open('/C:/1.jpg')]]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body
Request
Header
Name | Type | Description |
---|---|---|
Authorization | String | schema + “ “ + token |
Content-Type | String | multipart/form-data |
Accept | String | application/json |
Path Parameter
Name | Type | Required | Description |
---|---|---|---|
serviceType | String | YES | 이미지가 사용 될 서비스 타입(MMS, RCS, FRIENDTALK) |
msgType | String | NO | 상세 메시지 타입 *카카오 친구톡 이미지 업로드 시 필수 (FI: 친구톡 이미지 FW: 친구톡 와이드 이미지 FL: 친구톡 와이드 아이템 리스트이미지 FC: 친구톡 캐러셀 이미지) |
Body
Name | Type | Required | Description |
---|---|---|---|
file | Binary | YES | 이미지 파일 바이너리 |
Response
Header
Name | Type | Description |
---|---|---|
Content-Type | String | application/json |
Body
Name | Type | Description |
---|---|---|
code | String(4) | API호출 결과 코드 |
result | String | API호출 결과 설명 |
data | Object | API호출 결과 데이터 |
참고사항
서비스 별 지원 이미지 파일(Filename extension) 사양
MMS
이미지 형식: jpg(jpeg)
제한 사이즈: 가로 1,500 세로 1,440 이하
최대 파일 용량: 300KB
RCS
이미지 형식: jpg(jpeg), bmp, png, gif
최대 파일 용량: 1MB
FRIENDTALK
이미지 형식: jpg(jpeg), png
제한 사이즈
친구톡 이미지: 가로 500px 이상, 가로:세로 비율 2:1 이상 3:4 이하
친구톡 와이드 이미지: 가로 800px 세로 600px 고정
친구톡 와이드 아이템 리스트 이미지: 가로 400px, 세로 400px ~ 가로 800px~세로 400px
친구톡 케러셀 이미지: 가로 500px 이상, 가로:세로 비율 2:1 이상 3:4 이하
최대 파일 용량: 500KB(친구톡), 2MB(친구톡 와이드, 친구톡 아이템 리스트, 친구톡 캐러셀)