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

๋นˆ ๊ตฌ๋ฉ ์ฑ„์šฐ๊ธฐ

[Library] Glide asFile()/downloadOnly()๋กœ ์–ป์€ ํŒŒ์ผ์˜ ํ™•์žฅ์ž .0

remote url๋กœ ๋ฐ›์€ ์ด๋ฏธ์ง€๋ฅผ local์— ์ €์žฅํ•˜๋Š” ์†์‰ฌ์šด ๋ฐฉ๋ฒ•์œผ๋กœ Glide์˜ asFile(), downloadOnly()๊ฐ€ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ์•˜๋‹ค.

์ €์žฅ๋œ ํŒŒ์ผ์˜ ์ด๋ฆ„์„ ํ™•์ธํ•ด๋ณด๋‹ˆ ํ™•์žฅ์ž๊ฐ€ .0์œผ๋กœ ๋‚˜์™”๋‹ค.

 

github.com/bumptech/glide/issues/1620

 

The cache file extension · Issue #1620 · bumptech/glide

Glide Version: 3.7.1 Device/Android Version: Xiaomi Redmi Note 3 Pro / 6.0 The cache file has an extension ".0" . Can i modify it? i want a .gif extension

github.com

ํ•ด๊ฒฐ์ฑ…์ด ์žˆ์—ˆ๋‹ค.

 

val directory = File(context.cacheDir, "image").also {
    if (!it.exists()) {
        it.mkdirs()
    }
}

val cacheFile = Glide.with(context).asFile().load(this).submit().get()
val file = cacheFile.copyTo(File(directory, "image_$name.jpg"), true) // ์‚ฌ์šฉํ•  ํŒŒ์ผ

cacheFile.delete()

 

ํŒŒ์ผ์„ ์นดํ”ผํ•ด์„œ ์ด๋ฆ„์— ํ™•์žฅ์ž๋ฅผ ์ง€์ •ํ•ด์ฃผ๋ฉด ๋œ๋‹ค. asFile()/downloadOnly()๋กœ ๊ฐ€์ ธ์˜จ ์บ์‹œ ํŒŒ์ผ์€ ์ง€์›Œ์ค€๋‹ค.