Cloudinary๋?
Cloudinary๋ ์ด๋ฏธ์ง๋ ๋์์์ ์ฝ๊ฒ ์ ๋ก๋ํ๊ณ , ์ ์ฅํ๊ณ , ๋ณด์ฌ์ฃผ๊ณ , ๊ด๋ฆฌํ ์ ์๊ฒ ํด์ฃผ๋ ์๋น์ค
์ฝ๊ฒ ๋งํ๋ฉด,“์ด๋ฏธ์ง์ฉ ํด๋ผ์ฐ๋ ์ ์ฅ์ + ์ด๋ฏธ์ง ๋ณํ ์๋ํ ๋๊ตฌ”
| ์ด๋ฏธ์ง ์ ๋ก๋ | ์๋ฒ๋ ํ๋ก ํธ์์ ์ด๋ฏธ์ง ๋ณด๋ด๋ฉด ์ ์ฅ๋จ |
| ์๋ URL ๋ฐ๊ธ | ์ ๋ก๋ํ๋ฉด ๊ณง๋ฐ๋ก ์ด๋ฏธ์ง ์ฃผ์(URL) ๋ฐํ |
| ์ด๋ฏธ์ง ์ต์ ํ | ์๋ ์์ถ, ๋ฆฌ์ฌ์ด์ฆ, ์ธ๋ค์ผ ์์ฑ |
| CDN ์ ๊ณต | Cloudinary ์๋ฒ๊ฐ ์ ์ธ๊ณ์ ํผ์ ธ ์์ด์ ๋น ๋ฅด๊ฒ ๋ก๋ฉ |
| ๋์์๋ ์ง์ | ์ด๋ฏธ์ง๋ ๊ฑฐ์ ๋๊ฐ์ด ์ฒ๋ฆฌ ๊ฐ๋ฅ |
Amazon์ S3์ฒ๋ผ ์๊ฐํ๋ฉด ๋๋ค!
Image and Video Upload, Storage, Optimization and CDN
Streamline media management and improve user experience by automatically delivering images and videos, enhanced and optimized for every user.
cloudinary.com
์ฌ์ดํธ์ ๊ฐ์ ํ๊ฒ ๋๋ฉด

๋ผ๋ ๋ฉ์ธ์ง๊ฐ ๋จ๋๋ฐ ์ฐ๋ฆฌ๋ ๊ฐ๋ฐ์๋๊น ์์๊ป ์ ํํด์ฃผ๋ฉด ๋๋ค.
๊ทธ๋ฌ๋ฉด ํด๋น ํ์ด์ง๋ก ๋์ด๊ฐ๋๋ฐ ์ฌ๊ธฐ์ view key ๋ฒํผ์ ๋๋ฅด๋ฉด ์ฌ์ฉํ api key๋ฅผ ๋ณผ์์๋ค.

์ด์ build.gradle๊ณผ application.properties์ ํด๋ผ์ฐ๋๋๋ฆฌ ๊ด๋ จ ์ค์ ์ ์ถ๊ฐํด์ค๋ค
implementation 'com.cloudinary:cloudinary-http44:1.37.0'
# Cloudinary ์ค์
cloudinary.cloud-name=YOUR_NAME
cloudinary.api-key=YOUR_API_KEY
cloudinary.api-secret=YOUR_SECRET_KEY
์ด์ ์ฌ์ฉ์๊ฐ ์ ๋ก๋ํ ์ด๋ฏธ์ง ํ์ผ์ cloudinary ์๋ฒ์ ์ ๋ก๋ํ๊ณ url์ ๋ฐ์์ ๋ฆฌํดํ๋ ์๋น์ค๋ฅผ ๋ง๋ค์ด๋ณด์.
CloudinaryConfig
@Configuration
public class CloudinaryConfig {
@Value("${cloudinary.cloud-name}")
private String cloudName;
@Value("${cloudinary.api-key}")
private String apiKey;
@Value("${cloudinary.api-secret}")
private String apiSecret;
@Bean
public Cloudinary cloudinary() {
Map<String, String> config = new HashMap<>();
config.put("cloud_name", cloudName);
config.put("api_key", apiKey);
config.put("api_secret", apiSecret);
return new Cloudinary(config);
}
}
CloudinaryService
@Service
@RequiredArgsConstructor
public class CloudinaryService {
private final Cloudinary cloudinary;
public String uploadImage(MultipartFile file) {
try {
Map uploadResult = cloudinary.uploader().upload(file.getBytes(), Map.of());
return uploadResult.get("secure_url").toString();
} catch (IOException e) {
throw new RuntimeException("์ด๋ฏธ์ง ์
๋ก๋ ์คํจ", e);
}
}
}
'๐๏ธ ๋ฐฑ์๋ > โ๏ธCloud' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| # Railway - ๋ฌด๋ฃ postgres ์๋ฒ ์ฌ์ฉํด๋ณด๊ธฐ (1) | 2025.08.11 |
|---|---|
| # Render - spring boot ํ๊ฒฝ ์น์๋น์ค ๋ฐฐํฌํ๊ธฐ (7) | 2025.07.10 |
| # ๋ฌด๋ฃ๋ก ๋ฐฐํฌํ ์ ์๋ ์ฌ์ดํธ Render (DB๊น์ง!) (1) | 2025.04.15 |
| # AWS ํด์ง - ๊ฒฐ์ ์๋๊ฒ ์น ๋ค ์ญ์ ํ๊ธฐ (1) | 2025.02.25 |