mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-21 00:54:46 +08:00
Remove param format
from FileCacheStrategy.newImageCache
This commit is contained in:
parent
d80ab1608a
commit
5cd027dfa9
@ -67,7 +67,7 @@ actual interface FileCacheStrategy {
|
|||||||
*/
|
*/
|
||||||
@MiraiExperimentalAPI
|
@MiraiExperimentalAPI
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun newImageCache(input: URL, format: String = "png"): ExternalImage
|
fun newImageCache(input: URL): ExternalImage
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认的缓存方案, 使用系统临时文件夹存储.
|
* 默认的缓存方案, 使用系统临时文件夹存储.
|
||||||
@ -105,7 +105,7 @@ actual interface FileCacheStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@MiraiExperimentalAPI
|
@MiraiExperimentalAPI
|
||||||
override fun newImageCache(input: URL, format: String): ExternalImage {
|
override fun newImageCache(input: URL): ExternalImage {
|
||||||
val out = ByteArrayOutputStream()
|
val out = ByteArrayOutputStream()
|
||||||
input.openConnection().getInputStream().use { it.copyTo(out) }
|
input.openConnection().getInputStream().use { it.copyTo(out) }
|
||||||
return newImageCache(out.toByteArray())
|
return newImageCache(out.toByteArray())
|
||||||
@ -118,7 +118,7 @@ actual interface FileCacheStrategy {
|
|||||||
@MiraiExperimentalAPI
|
@MiraiExperimentalAPI
|
||||||
class TempCache @JvmOverloads constructor(
|
class TempCache @JvmOverloads constructor(
|
||||||
/**
|
/**
|
||||||
* 缓存图片存放位置
|
* 缓存图片存放位置. 为 `null` 时使用主机系统的临时文件夹
|
||||||
*/
|
*/
|
||||||
val directory: File? = null
|
val directory: File? = null
|
||||||
) : FileCacheStrategy {
|
) : FileCacheStrategy {
|
||||||
@ -177,7 +177,7 @@ actual interface FileCacheStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@MiraiExperimentalAPI
|
@MiraiExperimentalAPI
|
||||||
override fun newImageCache(input: URL, format: String): ExternalImage {
|
override fun newImageCache(input: URL): ExternalImage {
|
||||||
return ExternalImage(createTempFile(directory = directory).apply {
|
return ExternalImage(createTempFile(directory = directory).apply {
|
||||||
deleteOnExit()
|
deleteOnExit()
|
||||||
input.openConnection().getInputStream().withOut(this.outputStream()) { copyTo(it) }
|
input.openConnection().getInputStream().withOut(this.outputStream()) { copyTo(it) }
|
||||||
@ -194,11 +194,6 @@ internal inline fun <I : Closeable, O : Closeable, R> I.withOut(output: O, block
|
|||||||
return use { output.use { block(this, output) } }
|
return use { output.use { block(this, output) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Copies this stream to the given output stream, returning the number of bytes copied
|
|
||||||
*
|
|
||||||
* **Note** It is the caller's responsibility to close both of these resources.
|
|
||||||
*/
|
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
internal fun Input.copyTo(out: OutputStream, bufferSize: Int = DEFAULT_BUFFER_SIZE): Long {
|
internal fun Input.copyTo(out: OutputStream, bufferSize: Int = DEFAULT_BUFFER_SIZE): Long {
|
||||||
var bytesCopied: Long = 0
|
var bytesCopied: Long = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user