파일 업로드

Request

1
POST https://api.coolsms.co.kr/storage/v1/files
Copied!
파일을 업로드합니다.
타입별 제한 사이즈
  • [KAKAO] : 500KB
  • [MMS] : 200KB
  • [DOCUMENT] : 2MB

Authorization 인증 필요 [?]

계정 권한
회원 권한
계정 상태
회원 상태
계정 인증
storage:write
ACTIVE
ACTIVE

Request Structure

1
{
2
"file": "string",
3
"name": "string",
4
"type": "string",
5
"link": "string"
6
}
Copied!

Body Params

Name
Type
Required
Description
file
string
O
파일 (base64 encoded)
name
string
파일 이름
type
string
문서 타입(DOCUMENT, KAKAO, MMS)
link
string
이미지를 눌렀을 때 이동할 링크

Response

Response Structure

1
{
2
"kakao": {
3
"daou": "string",
4
"biztalk": "string"
5
},
6
"type": "string",
7
"originalName": "string",
8
"link": "string",
9
"fileId": "string",
10
"name": "string",
11
"url": "string",
12
"accountId": "string",
13
"references": [
14
"string"
15
],
16
"dateCreated": "date",
17
"dateUpdated": "date"
18
}
Copied!

Response Description

Response /

Name
Type
Should Return
Description
kakao
object
카카오 채널 발송(알림톡, 친구톡)에 사용되는 정보
type
string
O
문서 타입(DOCUMENT, KAKAO, MMS)
originalName
string
O
원본 파일 이름
link
string
이미지를 눌렀을 때 이동할 링크
fileId
string
O
파일 고유 아이디
name
string
O
파일 이름
url
string
O
파일 주소
accountId
string
O
계정 고유 아이디
references
array
해당 파일 사용처 목록
dateCreated
date
O
최초 생성 날짜
dateUpdated
date
O
최근 수정 날짜

Response / kakao

Name
Type
Should Return
Description
daou
string
다우기술에 등록되어있는지 여부
biztalk
string
비즈톡에 등록되어있는지 여부

Samples

PNG 업로드

Sample Request
1
{
2
"file": "iVBORw0KGgoAAAANSUhEUgAAAyA..."
3
}
Copied!
Sample Response
1
{
2
"kakao": {
3
"daou": null,
4
"biztalk": null
5
},
6
"type": "DOCUMENT",
7
"originalName": "I8xNI.png",
8
"link": null,
9
"width": 800,
10
"height": 500,
11
"fileSize": 503111,
12
"fileId": "ST01FP200923043341379MfcAwzt2BHu",
13
"name": "I8xNI.png",
14
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FP200923043341379MfcAwzt2BHu",
15
"accountId": "53901839183913",
16
"references": [],
17
"dateCreated": "2020-09-23T03:33:41.479Z",
18
"dateUpdated": "2020-09-23T03:33:41.479Z"
19
}
Copied!
Sample Code
NODE
PHP
PYTHON
CURL
RUBY
GO
JAVA
1
var request = require('request');
2
3
var options = {
4
headers: {
5
Authorization:
6
'HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4',
7
'Content-Type': 'application/json'
8
},
9
body: {
10
file: 'iVBORw0KGgoAAAANSUhEUgAAAyA...'
11
},
12
method: 'POST',
13
json: true,
14
url: 'http://api.coolsms.co.kr/storage/v1/files'
15
};
16
17
request(options, function(error, response, body) {
18
if (error) throw error;
19
console.log('result :', body);
20
});
Copied!
1
<?php
2
$url = "http://api.coolsms.co.kr/storage/v1/files";
3
$data = '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA..."}';
4
5
$options = array(
6
'http' => array(
7
'header' => "Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4\r\n" . "Content-Type: application/json\r\n",
8
'content' => $data,
9
'method' => 'POST'
10
)
11
);
12
13
$context = stream_context_create($options);
14
$result = file_get_contents($url, false, $context);
15
16
var_dump($result);
Copied!
1
import requests
2
3
url = "http://api.coolsms.co.kr/storage/v1/files"
4
headers = {
5
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
6
"Content-Type": "application/json"
7
}
8
data = '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA..."}'
9
10
response = requests.post(url, headers=headers, data=data)
11
print(response.status_code)
12
print(response.text)
Copied!
1
#!/bin/bash
2
curl -X POST \
3
-H 'Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4' \
4
-H 'Content-Type: application/json' \
5
-d '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA..."}' \
6
http://api.coolsms.co.kr/storage/v1/files
Copied!
1
require 'net/http'
2
require 'uri'
3
require 'json'
4
5
uri = URI.parse("http://api.coolsms.co.kr/storage/v1/files")
6
7
headers = {
8
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
9
"Content-Type": "application/json"
10
}
11
data = {
12
"file": "iVBORw0KGgoAAAANSUhEUgAAAyA..."
13
}
14
http = Net::HTTP.new(uri.host, uri.port)
15
request = Net::HTTP::Post.new(uri.request_uri, headers)
16
request.body = data.to_json
17
18
response = http.request(request)
19
puts response.code
20
puts response.body
Copied!
1
package main
2
3
import (
4
"fmt"
5
"io/ioutil"
6
"net/http"
7
"strings"
8
)
9
10
func main() {
11
uri := "http://api.coolsms.co.kr/storage/v1/files"
12
data := strings.NewReader(`{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA..."}`)
13
14
req, err := http.NewRequest("POST", uri, data)
15
if err != nil { panic(err) }
16
17
req.Header.Set("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4")
18
req.Header.Set("Content-Type", "application/json")
19
20
client := &http.Client{}
21
resp, err := client.Do(req)
22
if err != nil { panic(err) }
23
defer resp.Body.Close()
24
25
bytes, _ := ioutil.ReadAll(resp.Body)
26
str := string(bytes)
27
fmt.Println(str)
28
}
Copied!
1
package solapi;
2
3
import java.io.BufferedReader;
4
import java.io.DataOutputStream;
5
import java.io.InputStreamReader;
6
import java.net.HttpURLConnection;
7
import java.net.URL;
8
9
public class Request {
10
public static void main(String[] args) throws Exception {
11
String targetUrl = "http://api.coolsms.co.kr/storage/v1/files";
12
String parameters = "{\"file\":\"iVBORw0KGgoAAAANSUhEUgAAAyA...\"}";
13
14
URL url = new URL(targetUrl);
15
HttpURLConnection con = (HttpURLConnection) url.openConnection();
16
17
con.setRequestMethod("POST");
18
19
con.setRequestProperty("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4");
20
con.setRequestProperty("Content-Type", "application/json");
21
22
con.setDoOutput(true);
23
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
24
wr.writeBytes(parameters);
25
wr.flush();
26
wr.close();
27
28
int responseCode = con.getResponseCode();
29
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
30
String line;
31
StringBuffer response = new StringBuffer();
32
while ((line = in.readLine()) != null) {
33
response.append(line);
34
}
35
in.close();
36
37
System.out.println("HTTP response code : " + responseCode);
38
System.out.println("HTTP body : " + response.toString());
39
}
40
}
Copied!

PNG 업로드 (이름 포함)

Sample Request
1
{
2
"file": "iVBORw0KGgoAAAANSUhEUgAAAyA...",
3
"name": "smile.png"
4
}
Copied!
Sample Response
1
{
2
"kakao": {
3
"daou": null,
4
"biztalk": null
5
},
6
"type": "DOCUMENT",
7
"originalName": "smile.png",
8
"link": null,
9
"width": 800,
10
"height": 500,
11
"fileSize": 503111,
12
"fileId": "ST01FP200923043341529iTxkKMOVoO2",
13
"name": "Cm40E.png",
14
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FP200923043341529iTxkKMOVoO2",
15
"accountId": "53901839183913",
16
"references": [],
17
"dateCreated": "2020-09-23T03:33:41.620Z",
18
"dateUpdated": "2020-09-23T03:33:41.620Z"
19
}
Copied!
Sample Code
NODE
PHP
PYTHON
CURL
RUBY
GO
JAVA
1
var request = require('request');
2
3
var options = {
4
headers: {
5
Authorization:
6
'HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4',
7
'Content-Type': 'application/json'
8
},
9
body: {
10
file: 'iVBORw0KGgoAAAANSUhEUgAAAyA...',
11
name: 'smile.png'
12
},
13
method: 'POST',
14
json: true,
15
url: 'http://api.coolsms.co.kr/storage/v1/files'
16
};
17
18
request(options, function(error, response, body) {
19
if (error) throw error;
20
console.log('result :', body);
21
});
Copied!
1
<?php
2
$url = "http://api.coolsms.co.kr/storage/v1/files";
3
$data = '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA...","name":"smile.png"}';
4
5
$options = array(
6
'http' => array(
7
'header' => "Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4\r\n" . "Content-Type: application/json\r\n",
8
'content' => $data,
9
'method' => 'POST'
10
)
11
);
12
13
$context = stream_context_create($options);
14
$result = file_get_contents($url, false, $context);
15
16
var_dump($result);
Copied!
1
import requests
2
3
url = "http://api.coolsms.co.kr/storage/v1/files"
4
headers = {
5
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
6
"Content-Type": "application/json"
7
}
8
data = '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA...","name":"smile.png"}'
9
10
response = requests.post(url, headers=headers, data=data)
11
print(response.status_code)
12
print(response.text)
Copied!
1
#!/bin/bash
2
curl -X POST \
3
-H 'Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4' \
4
-H 'Content-Type: application/json' \
5
-d '{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA...","name":"smile.png"}' \
6
http://api.coolsms.co.kr/storage/v1/files
Copied!
1
require 'net/http'
2
require 'uri'
3
require 'json'
4
5
uri = URI.parse("http://api.coolsms.co.kr/storage/v1/files")
6
7
headers = {
8
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
9
"Content-Type": "application/json"
10
}
11
data = {
12
"file": "iVBORw0KGgoAAAANSUhEUgAAAyA...",
13
"name": "smile.png"
14
}
15
http = Net::HTTP.new(uri.host, uri.port)
16
request = Net::HTTP::Post.new(uri.request_uri, headers)
17
request.body = data.to_json
18
19
response = http.request(request)
20
puts response.code
21
puts response.body
Copied!
1
package main
2
3
import (
4
"fmt"
5
"io/ioutil"
6
"net/http"
7
"strings"
8
)
9
10
func main() {
11
uri := "http://api.coolsms.co.kr/storage/v1/files"
12
data := strings.NewReader(`{"file":"iVBORw0KGgoAAAANSUhEUgAAAyA...","name":"smile.png"}`)
13
14
req, err := http.NewRequest("POST", uri, data)
15
if err != nil { panic(err) }
16
17
req.Header.Set("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4")
18
req.Header.Set("Content-Type", "application/json")
19
20
client := &http.Client{}
21
resp, err := client.Do(req)
22
if err != nil { panic(err) }
23
defer resp.Body.Close()
24
25
bytes, _ := ioutil.ReadAll(resp.Body)
26
str := string(bytes)
27
fmt.Println(str)
28
}
Copied!
1
package solapi;
2
3
import java.io.BufferedReader;
4
import java.io.DataOutputStream;
5
import java.io.InputStreamReader;
6
import java.net.HttpURLConnection;
7
import java.net.URL;
8
9
public class Request {
10
public static void main(String[] args) throws Exception {
11
String targetUrl = "http://api.coolsms.co.kr/storage/v1/files";
12
String parameters = "{\"file\":\"iVBORw0KGgoAAAANSUhEUgAAAyA...\",\"name\":\"smile.png\"}";
13
14
URL url = new URL(targetUrl);
15
HttpURLConnection con = (HttpURLConnection) url.openConnection();
16
17
con.setRequestMethod("POST");
18
19
con.setRequestProperty("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4");
20
con.setRequestProperty("Content-Type", "application/json");
21
22
con.setDoOutput(true);
23
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
24
wr.writeBytes(parameters);
25
wr.flush();
26
wr.close();
27
28
int responseCode = con.getResponseCode();
29
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
30
String line;
31
StringBuffer response = new StringBuffer();
32
while ((line = in.readLine()) != null) {
33
response.append(line);
34
}
35
in.close();
36
37
System.out.println("HTTP response code : " + responseCode);
38
System.out.println("HTTP body : " + response.toString());
39
}
40
}
Copied!

JPG 업로드

Sample Request
1
{
2
"file": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
3
}
Copied!
Sample Response
1
{
2
"kakao": {
3
"daou": null,
4
"biztalk": null
5
},
6
"type": "DOCUMENT",
7
"originalName": "hDpGY.jpg",
8
"link": null,
9
"width": 1020,
10
"height": 510,
11
"fileSize": 124814,
12
"fileId": "ST01FJ200923043341643gYUXqmL5NyV",
13
"name": "hDpGY.jpg",
14
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FJ200923043341643gYUXqmL5NyV",
15
"accountId": "53901839183913",
16
"references": [],
17
"dateCreated": "2020-09-23T03:33:41.706Z",
18
"dateUpdated": "2020-09-23T03:33:41.706Z"
19
}
Copied!
Sample Code
NODE
PHP
PYTHON
CURL
RUBY
GO
JAVA
1
var request = require('request');
2
3
var options = {
4
headers: {
5
Authorization:
6
'HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4',
7
'Content-Type': 'application/json'
8
},
9
body: {
10
file: '/9j/4AAQSkZJRgABAQAAAQABAAD...'
11
},
12
method: 'POST',
13
json: true,
14
url: 'http://api.coolsms.co.kr/storage/v1/files'
15
};
16
17
request(options, function(error, response, body) {
18
if (error) throw error;
19
console.log('result :', body);
20
});
Copied!
1
<?php
2
$url = "http://api.coolsms.co.kr/storage/v1/files";
3
$data = '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}';
4
5
$options = array(
6
'http' => array(
7
'header' => "Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4\r\n" . "Content-Type: application/json\r\n",
8
'content' => $data,
9
'method' => 'POST'
10
)
11
);
12
13
$context = stream_context_create($options);
14
$result = file_get_contents($url, false, $context);
15
16
var_dump($result);
Copied!
1
import requests
2
3
url = "http://api.coolsms.co.kr/storage/v1/files"
4
headers = {
5
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
6
"Content-Type": "application/json"
7
}
8
data = '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}'
9
10
response = requests.post(url, headers=headers, data=data)
11
print(response.status_code)
12
print(response.text)
Copied!
1
#!/bin/bash
2
curl -X POST \
3
-H 'Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4' \
4
-H 'Content-Type: application/json' \
5
-d '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}' \
6
http://api.coolsms.co.kr/storage/v1/files
Copied!
1
require 'net/http'
2
require 'uri'
3
require 'json'
4
5
uri = URI.parse("http://api.coolsms.co.kr/storage/v1/files")
6
7
headers = {
8
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
9
"Content-Type": "application/json"
10
}
11
data = {
12
"file": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
13
}
14
http = Net::HTTP.new(uri.host, uri.port)
15
request = Net::HTTP::Post.new(uri.request_uri, headers)
16
request.body = data.to_json
17
18
response = http.request(request)
19
puts response.code
20
puts response.body
Copied!
1
package main
2
3
import (
4
"fmt"
5
"io/ioutil"
6
"net/http"
7
"strings"
8
)
9
10
func main() {
11
uri := "http://api.coolsms.co.kr/storage/v1/files"
12
data := strings.NewReader(`{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}`)
13
14
req, err := http.NewRequest("POST", uri, data)
15
if err != nil { panic(err) }
16
17
req.Header.Set("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4")
18
req.Header.Set("Content-Type", "application/json")
19
20
client := &http.Client{}
21
resp, err := client.Do(req)
22
if err != nil { panic(err) }
23
defer resp.Body.Close()
24
25
bytes, _ := ioutil.ReadAll(resp.Body)
26
str := string(bytes)
27
fmt.Println(str)
28
}
Copied!
1
package solapi;
2
3
import java.io.BufferedReader;
4
import java.io.DataOutputStream;
5
import java.io.InputStreamReader;
6
import java.net.HttpURLConnection;
7
import java.net.URL;
8
9
public class Request {
10
public static void main(String[] args) throws Exception {
11
String targetUrl = "http://api.coolsms.co.kr/storage/v1/files";
12
String parameters = "{\"file\":\"/9j/4AAQSkZJRgABAQAAAQABAAD...\"}";
13
14
URL url = new URL(targetUrl);
15
HttpURLConnection con = (HttpURLConnection) url.openConnection();
16
17
con.setRequestMethod("POST");
18
19
con.setRequestProperty("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4");
20
con.setRequestProperty("Content-Type", "application/json");
21
22
con.setDoOutput(true);
23
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
24
wr.writeBytes(parameters);
25
wr.flush();
26
wr.close();
27
28
int responseCode = con.getResponseCode();
29
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
30
String line;
31
StringBuffer response = new StringBuffer();
32
while ((line = in.readLine()) != null) {
33
response.append(line);
34
}
35
in.close();
36
37
System.out.println("HTTP response code : " + responseCode);
38
System.out.println("HTTP body : " + response.toString());
39
}
40
}
Copied!

JPEG 업로드

Sample Request
1
{
2
"file": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
3
}
Copied!
Sample Response
1
{
2
"kakao": {
3
"daou": null,
4
"biztalk": null
5
},
6
"type": "DOCUMENT",
7
"originalName": "MmNcF.jpg",
8
"link": null,
9
"width": 629,
10
"height": 436,
11
"fileSize": 127596,
12
"fileId": "ST01FJ200923043341723qlGm1hg3YcS",
13
"name": "MmNcF.jpg",
14
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FJ200923043341723qlGm1hg3YcS",
15
"accountId": "53901839183913",
16
"references": [],
17
"dateCreated": "2020-09-23T03:33:41.814Z",
18
"dateUpdated": "2020-09-23T03:33:41.814Z"
19
}
Copied!
Sample Code
NODE
PHP
PYTHON
CURL
RUBY
GO
JAVA
1
var request = require('request');
2
3
var options = {
4
headers: {
5
Authorization:
6
'HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4',
7
'Content-Type': 'application/json'
8
},
9
body: {
10
file: '/9j/4AAQSkZJRgABAQAAAQABAAD...'
11
},
12
method: 'POST',
13
json: true,
14
url: 'http://api.coolsms.co.kr/storage/v1/files'
15
};
16
17
request(options, function(error, response, body) {
18
if (error) throw error;
19
console.log('result :', body);
20
});
Copied!
1
<?php
2
$url = "http://api.coolsms.co.kr/storage/v1/files";
3
$data = '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}';
4
5
$options = array(
6
'http' => array(
7
'header' => "Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4\r\n" . "Content-Type: application/json\r\n",
8
'content' => $data,
9
'method' => 'POST'
10
)
11
);
12
13
$context = stream_context_create($options);
14
$result = file_get_contents($url, false, $context);
15
16
var_dump($result);
Copied!
1
import requests
2
3
url = "http://api.coolsms.co.kr/storage/v1/files"
4
headers = {
5
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
6
"Content-Type": "application/json"
7
}
8
data = '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}'
9
10
response = requests.post(url, headers=headers, data=data)
11
print(response.status_code)
12
print(response.text)
Copied!
1
#!/bin/bash
2
curl -X POST \
3
-H 'Authorization: HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4' \
4
-H 'Content-Type: application/json' \
5
-d '{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}' \
6
http://api.coolsms.co.kr/storage/v1/files
Copied!
1
require 'net/http'
2
require 'uri'
3
require 'json'
4
5
uri = URI.parse("http://api.coolsms.co.kr/storage/v1/files")
6
7
headers = {
8
"Authorization": "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4",
9
"Content-Type": "application/json"
10
}
11
data = {
12
"file": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
13
}
14
http = Net::HTTP.new(uri.host, uri.port)
15
request = Net::HTTP::Post.new(uri.request_uri, headers)
16
request.body = data.to_json
17
18
response = http.request(request)
19
puts response.code
20
puts response.body
Copied!
1
package main
2
3
import (
4
"fmt"
5
"io/ioutil"
6
"net/http"
7
"strings"
8
)
9
10
func main() {
11
uri := "http://api.coolsms.co.kr/storage/v1/files"
12
data := strings.NewReader(`{"file":"/9j/4AAQSkZJRgABAQAAAQABAAD..."}`)
13
14
req, err := http.NewRequest("POST", uri, data)
15
if err != nil { panic(err) }
16
17
req.Header.Set("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4")
18
req.Header.Set("Content-Type", "application/json")
19
20
client := &http.Client{}
21
resp, err := client.Do(req)
22
if err != nil { panic(err) }
23
defer resp.Body.Close()
24
25
bytes, _ := ioutil.ReadAll(resp.Body)
26
str := string(bytes)
27
fmt.Println(str)
28
}
Copied!
1
package solapi;
2
3
import java.io.BufferedReader;
4
import java.io.DataOutputStream;
5
import java.io.InputStreamReader;
6
import java.net.HttpURLConnection;
7
import java.net.URL;
8
9
public class Request {
10
public static void main(String[] args) throws Exception {
11
String targetUrl = "http://api.coolsms.co.kr/storage/v1/files";
12
String parameters = "{\"file\":\"/9j/4AAQSkZJRgABAQAAAQABAAD...\"}";
13
14
URL url = new URL(targetUrl);
15
HttpURLConnection con = (HttpURLConnection) url.openConnection();
16
17
con.setRequestMethod("POST");
18
19
con.setRequestProperty("Authorization", "HMAC-SHA256 apiKey=NCSAYU7YDBXYORXC, date=2019-07-01T00:41:48Z, salt=jqsba2jxjnrjor, signature=1779eac71a24cbeeadfa7263cb84b7ea0af1714f5c0270aa30ffd34600e363b4");
20
con.setRequestProperty("Content-Type", "application/json");
21
22
con.setDoOutput(true);
23
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
24
wr.writeBytes(parameters);
25
wr.flush();
26
wr.close();
27
28
int responseCode = con.getResponseCode();
29
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
30
String line;
31
StringBuffer response = new StringBuffer();
32
while ((line = in.readLine()) != null) {
33
response.append(line);
34
}
35
in.close();
36
37
System.out.println("HTTP response code : " + responseCode);
38
System.out.println("HTTP body : " + response.toString());
39
}
40
}