파일 업로드
Request
POST https://api.coolsms.co.kr/storage/v1/files
파일을 업로드합니다.
타입별 제한 사이즈
[KAKAO] : 500KB
[MMS] : 200KB
[DOCUMENT] : 2MB
Authorization 인증 필요 [?]
계정 권한 | 회원 권한 | 계정 상태 | 회원 상태 | 계정 인증 |
|
|
|
Request Structure
{
"file": "string",
"name": "string",
"type": "string",
"link": "string"
}
Body Params
Name | Type | Required | Description |
file |
| O | 파일 (base64 encoded) |
name |
| 파일 이름 | |
type |
| 문서 타입(DOCUMENT, KAKAO, MMS) | |
link |
| 이미지를 눌렀을 때 이동할 링크 |
Response
Response Structure
{
"kakao": {
"daou": "string",
"biztalk": "string"
},
"type": "string",
"originalName": "string",
"link": "string",
"fileId": "string",
"name": "string",
"url": "string",
"accountId": "string",
"references": [
"string"
],
"dateCreated": "date",
"dateUpdated": "date"
}
Response Description
Response /
Name | Type | Should Return | Description |
| 카카오 채널 발송(알림톡, 친구톡)에 사용되는 정보 | ||
type |
| O | 문서 타입(DOCUMENT, KAKAO, MMS) |
originalName |
| O | 원본 파일 이름 |
link |
| 이미지를 눌렀을 때 이동할 링크 | |
fileId |
| O | 파일 고유 아이디 |
name |
| O | 파일 이름 |
url |
| O | 파일 주소 |
accountId |
| O | 계정 고유 아이디 |
references |
| 해당 파일 사용처 목록 | |
dateCreated |
| O | 최초 생성 날짜 |
dateUpdated |
| O | 최근 수정 날짜 |
Response / kakao
Name | Type | Should Return | Description |
daou |
| 다우기술에 등록되어있는지 여부 | |
biztalk |
| 비즈톡에 등록되어있는지 여부 |
Samples
PNG 업로드
Sample Request
{
"file": "iVBORw0KGgoAAAANSUhEUgAAAyA..."
}
Sample Response
{
"kakao": {
"daou": null,
"biztalk": null
},
"type": "DOCUMENT",
"originalName": "I8xNI.png",
"link": null,
"width": 800,
"height": 500,
"fileSize": 503111,
"fileId": "ST01FP200923043341379MfcAwzt2BHu",
"name": "I8xNI.png",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FP200923043341379MfcAwzt2BHu",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:33:41.479Z",
"dateUpdated": "2020-09-23T03:33:41.479Z"
}
Sample Code
var request = require('request');
var options = {
headers: {
Authorization:
'HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4',
'Content-Type': 'application/json'
},
body: {
file: 'iVBORw0KGgoAAAANSUhEUgAAAyA...'
},
method: 'POST',
json: true,
url: 'http://api.coolsms.co.kr/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
<?php
$url = "http://api.coolsms.co.kr/storage/v1/files";
$data = '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA..."}';
$options = array(
'http' => array(
'header' => "Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4\r\n" . "Content-Type: application/json\r\n",
'content' => $data,
'method' => 'POST'
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
import requests
url = "http://api.coolsms.co.kr/storage/v1/files"
headers = {
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
"Content-Type": "application/json"
}
data = '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA..."}'
response = requests.post(url, headers=headers, data=data)
print(response.status_code)
print(response.text)
#!/bin/bash
curl -X POST \
-H 'Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4' \
-H 'Content-Type: application/json' \
-d '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA..."}' \
http://api.coolsms.co.kr/storage/v1/files
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.coolsms.co.kr/storage/v1/files")
headers = {
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
"Content-Type": "application/json"
}
data = {
"file": "iVBORw0KGgoAAAANSUhEUgAAAyA..."
}
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, headers)
request.body = data.to_json
response = http.request(request)
puts response.code
puts response.body
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.coolsms.co.kr/storage/v1/files"
data := strings.NewReader(`{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA..."}`)
req, err := http.NewRequest("POST", uri, data)
if err != nil { panic(err) }
req.Header.Set("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
bytes, _ := ioutil.ReadAll(resp.Body)
str := string(bytes)
fmt.Println(str)
}
package solapi;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Request {
public static void main(String[] args) throws Exception {
String targetUrl = "http://api.coolsms.co.kr/storage/v1/files";
String parameters = "{\"file\":\"iVBORw0KGgoAAAANSUhEUgAAAyA...\"}";
URL url = new URL(targetUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(parameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
StringBuffer response = new StringBuffer();
while ((line = in.readLine()) != null) {
response.append(line);
}
in.close();
System.out.println("HTTP response code : " + responseCode);
System.out.println("HTTP body : " + response.toString());
}
}
PNG 업로드 (이름 포함)
Sample Request
{
"file": "iVBORw0KGgoAAAANSUhEUgAAAyA...",
"name": "smile.png"
}
Sample Response
{
"kakao": {
"daou": null,
"biztalk": null
},
"type": "DOCUMENT",
"originalName": "smile.png",
"link": null,
"width": 800,
"height": 500,
"fileSize": 503111,
"fileId": "ST01FP200923043341529iTxkKMOVoO2",
"name": "Cm40E.png",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FP200923043341529iTxkKMOVoO2",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:33:41.620Z",
"dateUpdated": "2020-09-23T03:33:41.620Z"
}
Sample Code
var request = require('request');
var options = {
headers: {
Authorization:
'HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4',
'Content-Type': 'application/json'
},
body: {
file: 'iVBORw0KGgoAAAANSUhEUgAAAyA...',
name: 'smile.png'
},
method: 'POST',
json: true,
url: 'http://api.coolsms.co.kr/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
<?php
$url = "http://api.coolsms.co.kr/storage/v1/files";
$data = '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA...","name":"smile.png"}';
$options = array(
'http' => array(
'header' => "Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4\r\n" . "Content-Type: application/json\r\n",
'content' => $data,
'method' => 'POST'
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
import requests
url = "http://api.coolsms.co.kr/storage/v1/files"
headers = {
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
"Content-Type": "application/json"
}
data = '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA...","name":"smile.png"}'
response = requests.post(url, headers=headers, data=data)
print(response.status_code)
print(response.text)
#!/bin/bash
curl -X POST \
-H 'Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4' \
-H 'Content-Type: application/json' \
-d '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA...","name":"smile.png"}' \
http://api.coolsms.co.kr/storage/v1/files
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.coolsms.co.kr/storage/v1/files")
headers = {
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
"Content-Type": "application/json"
}
data = {
"file": "iVBORw0KGgoAAAANSUhEUgAAAyA...",
"name": "smile.png"
}
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, headers)
request.body = data.to_json
response = http.request(request)
puts response.code
puts response.body
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.coolsms.co.kr/storage/v1/files"
data := strings.NewReader(`{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA...","name":"smile.png"}`)
req, err := http.NewRequest("POST", uri, data)
if err != nil { panic(err) }
req.Header.Set("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
bytes, _ := ioutil.ReadAll(resp.Body)
str := string(bytes)
fmt.Println(str)
}
package solapi;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Request {
public static void main(String[] args) throws Exception {
String targetUrl = "http://api.coolsms.co.kr/storage/v1/files";
String parameters = "{\"file\":\"iVBORw0KGgoAAAANSUhEUgAAAyA...\",\"name\":\"smile.png\"}";
URL url = new URL(targetUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(parameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
StringBuffer response = new StringBuffer();
while ((line = in.readLine()) != null) {
response.append(line);
}
in.close();
System.out.println("HTTP response code : " + responseCode);
System.out.println("HTTP body : " + response.toString());
}
}
JPG 업로드
Sample Request
{
"file": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
Sample Response
{
"kakao": {
"daou": null,
"biztalk": null
},
"type": "DOCUMENT",
"originalName": "hDpGY.jpg",
"link": null,
"width": 1020,
"height": 510,
"fileSize": 124814,
"fileId": "ST01FJ200923043341643gYUXqmL5NyV",
"name": "hDpGY.jpg",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FJ200923043341643gYUXqmL5NyV",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:33:41.706Z",
"dateUpdated": "2020-09-23T03:33:41.706Z"
}
Sample Code
var request = require('request');
var options = {
headers: {
Authorization:
'HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4',
'Content-Type': 'application/json'
},
body: {
file: '/9j/4AAQSkZJRgABAQAAAQABAAD...'
},
method: 'POST',
json: true,
url: 'http://api.coolsms.co.kr/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
<?php
$url = "http://api.coolsms.co.kr/storage/v1/files";
$data = '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}';
$options = array(
'http' => array(
'header' => "Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4\r\n" . "Content-Type: application/json\r\n",
'content' => $data,
'method' => 'POST'
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
import requests
url = "http://api.coolsms.co.kr/storage/v1/files"
headers = {
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
"Content-Type": "application/json"
}
data = '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}'
response = requests.post(url, headers=headers, data=data)
print(response.status_code)
print(response.text)
#!/bin/bash
curl -X POST \
-H 'Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4' \
-H 'Content-Type: application/json' \
-d '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}' \
http://api.coolsms.co.kr/storage/v1/files
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.coolsms.co.kr/storage/v1/files")
headers = {
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
"Content-Type": "application/json"
}
data = {
"file": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, headers)
request.body = data.to_json
response = http.request(request)
puts response.code
puts response.body
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.coolsms.co.kr/storage/v1/files"
data := strings.NewReader(`{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}`)
req, err := http.NewRequest("POST", uri, data)
if err != nil { panic(err) }
req.Header.Set("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
bytes, _ := ioutil.ReadAll(resp.Body)
str := string(bytes)
fmt.Println(str)
}
package solapi;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Request {
public static void main(String[] args) throws Exception {
String targetUrl = "http://api.coolsms.co.kr/storage/v1/files";
String parameters = "{\"file\":\"/9j/4AAQSkZJRgABAQAAAQABAAD...\"}";
URL url = new URL(targetUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(parameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
StringBuffer response = new StringBuffer();
while ((line = in.readLine()) != null) {
response.append(line);
}
in.close();
System.out.println("HTTP response code : " + responseCode);
System.out.println("HTTP body : " + response.toString());
}
}
JPEG 업로드
Sample Request
{
"file": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
Sample Response
{
"kakao": {
"daou": null,
"biztalk": null
},
"type": "DOCUMENT",
"originalName": "MmNcF.jpg",
"link": null,
"width": 629,
"height": 436,
"fileSize": 127596,
"fileId": "ST01FJ200923043341723qlGm1hg3YcS",
"name": "MmNcF.jpg",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FJ200923043341723qlGm1hg3YcS",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:33:41.814Z",
"dateUpdated": "2020-09-23T03:33:41.814Z"
}
Sample Code
var request = require('request');
var options = {
headers: {
Authorization:
'HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4',
'Content-Type': 'application/json'
},
body: {
file: '/9j/4AAQSkZJRgABAQAAAQABAAD...'
},
method: 'POST',
json: true,
url: 'http://api.coolsms.co.kr/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
<?php
$url = "http://api.coolsms.co.kr/storage/v1/files";
$data = '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}';
$options = array(
'http' => array(
'header' => "Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4\r\n" . "Content-Type: application/json\r\n",
'content' => $data,
'method' => 'POST'
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
import requests
url = "http://api.coolsms.co.kr/storage/v1/files"
headers = {
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
"Content-Type": "application/json"
}
data = '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}'
response = requests.post(url, headers=headers, data=data)
print(response.status_code)
print(response.text)
#!/bin/bash
curl -X POST \
-H 'Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4' \
-H 'Content-Type: application/json' \
-d '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}' \
http://api.coolsms.co.kr/storage/v1/files
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.coolsms.co.kr/storage/v1/files")
headers = {
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
"Content-Type": "application/json"
}
data = {
"file": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, headers)
request.body = data.to_json
response = http.request(request)
puts response.code
puts response.body
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.coolsms.co.kr/storage/v1/files"
data := strings.NewReader(`{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}`)
req, err := http.NewRequest("POST", uri, data)
if err != nil { panic(err) }
req.Header.Set("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
bytes, _ := ioutil.ReadAll(resp.Body)
str := string(bytes)
fmt.Println(str)
}
package solapi;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Request {
public static void main(String[] args) throws Exception {
String targetUrl = "http://api.coolsms.co.kr/storage/v1/files";
String parameters = "{\"file\":\"/9j/4AAQSkZJRgABAQAAAQABAAD...\"}";
URL url = new URL(targetUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(parameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
StringBuffer response = new StringBuffer();
while ((line = in.readLine()) != null) {
response.append(line);
}
in.close();
System.out.println("HTTP response code : " + responseCode);
System.out.println("HTTP body : " + response.toString());
}
}
TIF 업로드
Sample Request
{
"file": "SUkqAL42BADHwpjCvZPHwpjMx53..."
}
Sample Response
{
"kakao": {
"daou": null,
"biztalk": null
},
"type": "DOCUMENT",
"originalName": "Suebb.tif",
"link": null,
"width": null,
"height": null,
"fileSize": 276466,
"fileId": "ST01FT2009230433418362U1Ky0iPLFa",
"name": "Suebb.tif",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FT2009230433418362U1Ky0iPLFa",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:33:41.944Z",
"dateUpdated": "2020-09-23T03:33:41.944Z"
}
Sample Code
var request = require('request');
var options = {
headers: {
Authorization:
'HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4',
'Content-Type': 'application/json'
},
body: {
file: 'SUkqAL42BADHwpjCvZPHwpjMx53...'
},
method: 'POST',
json: true,
url: 'http://api.coolsms.co.kr/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
<?php
$url = "http://api.coolsms.co.kr/storage/v1/files";
$data = '{"file":"SUkqAL42BADHwpjCvZPHwpjMx53..."}';
$options = array(
'http' => array(
'header' => "Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4\r\n" . "Content-Type: application/json\r\n",
'content' => $data,
'method' => 'POST'
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
import requests
url = "http://api.coolsms.co.kr/storage/v1/files"
headers = {
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
"Content-Type": "application/json"
}
data = '{"file":"SUkqAL42BADHwpjCvZPHwpjMx53..."}'
response = requests.post(url, headers=headers, data=data)
print(response.status_code)
print(response.text)
#!/bin/bash
curl -X POST \
-H 'Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4' \
-H 'Content-Type: application/json' \
-d '{"file":"SUkqAL42BADHwpjCvZPHwpjMx53..."}' \
http://api.coolsms.co.kr/storage/v1/files
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.coolsms.co.kr/storage/v1/files")
headers = {
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
"Content-Type": "application/json"
}
data = {
"file": "SUkqAL42BADHwpjCvZPHwpjMx53..."
}
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, headers)
request.body = data.to_json
response = http.request(request)
puts response.code
puts response.body
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.coolsms.co.kr/storage/v1/files"
data := strings.NewReader(`{"file":"SUkqAL42BADHwpjCvZPHwpjMx53..."}`)
req, err := http.NewRequest("POST", uri, data)
if err != nil { panic(err) }
req.Header.Set("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
bytes, _ := ioutil.ReadAll(resp.Body)
str := string(bytes)
fmt.Println(str)
}
package solapi;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Request {
public static void main(String[] args) throws Exception {
String targetUrl = "http://api.coolsms.co.kr/storage/v1/files";
String parameters = "{\"file\":\"SUkqAL42BADHwpjCvZPHwpjMx53...\"}";
URL url = new URL(targetUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");