๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๊ณณ๊ฐ„์—์„œ ์ธ์‹ฌ๋‚œ๋‹ค/์‹ค๋ฌด

[Android] Uri๋กœ๋ถ€ํ„ฐ ํ™•์žฅ์ž ์–ป๊ธฐ

๋ฌธ์ œ

 uri๋กœ ์ ‘๊ทผํ•˜๋Š” data์˜ ํ™•์žฅ์ž๋ฅผ ์‰ฝ๊ฒŒ ํŒŒ์•…ํ•˜๊ณ  ์‹ถ๋‹ค.

(๋ถ„๋ช… ๋ˆ„๊ฐ€ ์ด๋Ÿฐ ๊ธฐ๋Šฅ์„ ๋งŒ๋“ค์–ด ๋†“์•˜์„ ๊ฒƒ์ด๋‹ค.๐Ÿค”)

 

์ฐพ์•˜๋‹ค

https://developer.android.com/reference/android/webkit/MimeTypeMap#getFileExtensionFromUrl(java.lang.String)

 

MimeTypeMap  |  Android Developers

 

developer.android.com

 

ํ™œ์šฉ

val extension = MimeTypeMap.getFileExtensionFromUrl(downloadUri.toString())?.let {
    ".$it"
}