Add flush

This commit is contained in:
Him188 2020-02-28 10:46:14 +08:00
parent 49f2329112
commit c90013b23f

View File

@ -93,6 +93,7 @@ fun URL.toExternalImage(): ExternalImage {
openStream().use { input ->
input.copyTo(output)
}
output.flush()
}
return file.toExternalImage()
}
@ -110,6 +111,7 @@ fun InputStream.toExternalImage(): ExternalImage {
val file = createTempFile().apply { deleteOnExit() }
file.outputStream().use {
this.copyTo(it)
it.flush()
}
this.close()
return file.toExternalImage()
@ -130,6 +132,7 @@ fun Input.toExternalImage(): ExternalImage {
val file = createTempFile().apply { deleteOnExit() }
file.outputStream().asOutput().use {
this.copyTo(it)
it.flush()
}
return file.toExternalImage()
}
@ -146,6 +149,7 @@ suspend fun ByteReadChannel.toExternalImage(): ExternalImage {
val file = createTempFile().apply { deleteOnExit() }
file.outputStream().use {
this.copyTo(it)
it.flush()
}
return file.suspendToExternalImage()