파일 업로드

Request

POST https://api.solapi.com/storage/v1/files

파일을 업로드합니다.

타입별 제한 사이즈

  • [KAKAO] : 500KB

  • [MMS] : 200KB

  • [DOCUMENT] : 2MB

Authorization 인증 필요 [?]

계정 권한

회원 권한

계정 상태

회원 상태

계정 인증

storage:write

ACTIVE

ACTIVE

Request Structure

{
"file": "string",
"name": "string",
"type": "string",
"link": "string"
}

Body Params

Name

Type

Required

Description

file

string

O

파일 (base64 encoded)

name

string

파일 이름

type

string

문서 타입(DOCUMENT, KAKAO, MMS)

link

string

이미지를 눌렀을 때 이동할 링크

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

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

{
"file": "iVBORw0KGgoAAAANSUhEUgAAAyA..."
}

Sample Response

{
"kakao": {
"daou": null,
"biztalk": null
},
"type": "DOCUMENT",
"originalName": "9XIiq.png",
"link": null,
"width": 800,
"height": 500,
"fileSize": 503111,
"fileId": "ST01FP200923042740594oism3eYSGkp",
"name": "9XIiq.png",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FP200923042740594oism3eYSGkp",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:27:40.722Z",
"dateUpdated": "2020-09-23T03:27:40.722Z"
}

Sample Code

NODE
PHP
PYTHON
CURL
RUBY
GO
JAVA
NODE
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.solapi.com/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
PHP
<?php
$url = "http://api.solapi.com/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);
PYTHON
import requests
url = "http://api.solapi.com/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)
CURL
#!/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.solapi.com/storage/v1/files
RUBY
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.solapi.com/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
GO
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.solapi.com/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)
}
JAVA
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.solapi.com/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": "ST01FP200923042740771cFpGzt93M8M",
"name": "DbWJ0.png",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FP200923042740771cFpGzt93M8M",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:27:40.845Z",
"dateUpdated": "2020-09-23T03:27:40.845Z"
}

Sample Code

NODE
PHP
PYTHON
CURL
RUBY
GO
JAVA
NODE
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.solapi.com/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
PHP
<?php
$url = "http://api.solapi.com/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);
PYTHON
import requests
url = "http://api.solapi.com/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)
CURL
#!/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.solapi.com/storage/v1/files
RUBY
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.solapi.com/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
GO
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.solapi.com/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)
}
JAVA
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.solapi.com/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": "bUEBm.jpg",
"link": null,
"width": 1020,
"height": 510,
"fileSize": 124814,
"fileId": "ST01FJ2009230427408726kPo30lKLCO",
"name": "bUEBm.jpg",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FJ2009230427408726kPo30lKLCO",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:27:40.932Z",
"dateUpdated": "2020-09-23T03:27:40.932Z"
}

Sample Code

NODE
PHP
PYTHON
CURL
RUBY
GO
JAVA
NODE
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.solapi.com/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
PHP
<?php
$url = "http://api.solapi.com/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);
PYTHON
import requests
url = "http://api.solapi.com/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)
CURL
#!/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.solapi.com/storage/v1/files
RUBY
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.solapi.com/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
GO
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.solapi.com/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)
}
JAVA
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.solapi.com/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": "Rjm1D.jpg",
"link": null,
"width": 629,
"height": 436,
"fileSize": 127596,
"fileId": "ST01FJ200923042740949JjchK8kCjIN",
"name": "Rjm1D.jpg",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FJ200923042740949JjchK8kCjIN",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:27:41.052Z",
"dateUpdated": "2020-09-23T03:27:41.052Z"
}

Sample Code

NODE
PHP
PYTHON
CURL
RUBY
GO
JAVA
NODE
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.solapi.com/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
PHP
<?php
$url = "http://api.solapi.com/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);
PYTHON
import requests
url = "http://api.solapi.com/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)
CURL
#!/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.solapi.com/storage/v1/files
RUBY
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.solapi.com/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
GO
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.solapi.com/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)
}
JAVA
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.solapi.com/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": "B0laK.tif",
"link": null,
"width": null,
"height": null,
"fileSize": 276466,
"fileId": "ST01FT200923042741078O6erQ9zF3fO",
"name": "B0laK.tif",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FT200923042741078O6erQ9zF3fO",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:27:41.169Z",
"dateUpdated": "2020-09-23T03:27:41.169Z"
}

Sample Code

NODE
PHP
PYTHON
CURL
RUBY
GO
JAVA
NODE
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.solapi.com/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
PHP
<?php
$url = "http://api.solapi.com/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);
PYTHON
import requests
url = "http://api.solapi.com/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)
CURL
#!/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.solapi.com/storage/v1/files
RUBY
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.solapi.com/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
GO
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.solapi.com/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)
}
JAVA
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.solapi.com/storage/v1/files";
String parameters = "{\"file\":\"SUkqAL42BADHwpjCvZPHwpjMx53...\"}";
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());
}
}

TIFF 업로드

Sample Request

{
"file": "SUkqAOT2DgDW397a4+Le5+bd5uX..."
}

Sample Response

{
"kakao": {
"daou": null,
"biztalk": null
},
"type": "DOCUMENT",
"originalName": "QObmC.tif",
"link": null,
"width": null,
"height": null,
"fileSize": 980964,
"fileId": "ST01FT2009230427412489DZaWmy82cf",
"name": "QObmC.tif",
"url": "https://coolsms-storage-test.s3.ap-northeast-2.amazonaws.com/53901839183913/ST01FT2009230427412489DZaWmy82cf",
"accountId": "53901839183913",
"references": [],
"dateCreated": "2020-09-23T03:27:41.393Z",
"dateUpdated": "2020-09-23T03:27:41.393Z"
}

Sample Code

NODE
PHP
PYTHON
CURL
RUBY
GO
JAVA
NODE
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: 'SUkqAOT2DgDW397a4+Le5+bd5uX...'
},
method: 'POST',
json: true,
url: 'http://api.solapi.com/storage/v1/files'
};
request(options, function(error, response, body) {
if (error) throw error;
console.log('result :', body);
});
PHP
<?php
$url = "http://api.solapi.com/storage/v1/files";
$data = '{"file":"SUkqAOT2DgDW397a4+Le5+bd5uX..."}';
$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);
PYTHON
import requests
url = "http://api.solapi.com/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":"SUkqAOT2DgDW397a4+Le5+bd5uX..."}'
response = requests.post(url, headers=headers, data=data)
print(response.status_code)
print(response.text)
CURL
#!/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":"SUkqAOT2DgDW397a4+Le5+bd5uX..."}' \
http://api.solapi.com/storage/v1/files
RUBY
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://api.solapi.com/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": "SUkqAOT2DgDW397a4+Le5+bd5uX..."
}
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
GO
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
uri := "http://api.solapi.com/storage/v1/files"
data := strings.NewReader(`{"file":"SUkqAOT2DgDW397a4+Le5+bd5uX..."}`)
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)
}
JAVA
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[]