Commit c90013b2 authored by Him188's avatar Him188

Add `flush`

parent 49f23291
...@@ -93,6 +93,7 @@ fun URL.toExternalImage(): ExternalImage { ...@@ -93,6 +93,7 @@ fun URL.toExternalImage(): ExternalImage {
openStream().use { input -> openStream().use { input ->
input.copyTo(output) input.copyTo(output)
} }
output.flush()
} }
return file.toExternalImage() return file.toExternalImage()
} }
...@@ -110,6 +111,7 @@ fun InputStream.toExternalImage(): ExternalImage { ...@@ -110,6 +111,7 @@ fun InputStream.toExternalImage(): ExternalImage {
val file = createTempFile().apply { deleteOnExit() } val file = createTempFile().apply { deleteOnExit() }
file.outputStream().use { file.outputStream().use {
this.copyTo(it) this.copyTo(it)
it.flush()
} }
this.close() this.close()
return file.toExternalImage() return file.toExternalImage()
...@@ -130,6 +132,7 @@ fun Input.toExternalImage(): ExternalImage { ...@@ -130,6 +132,7 @@ fun Input.toExternalImage(): ExternalImage {
val file = createTempFile().apply { deleteOnExit() } val file = createTempFile().apply { deleteOnExit() }
file.outputStream().asOutput().use { file.outputStream().asOutput().use {
this.copyTo(it) this.copyTo(it)
it.flush()
} }
return file.toExternalImage() return file.toExternalImage()
} }
...@@ -146,6 +149,7 @@ suspend fun ByteReadChannel.toExternalImage(): ExternalImage { ...@@ -146,6 +149,7 @@ suspend fun ByteReadChannel.toExternalImage(): ExternalImage {
val file = createTempFile().apply { deleteOnExit() } val file = createTempFile().apply { deleteOnExit() }
file.outputStream().use { file.outputStream().use {
this.copyTo(it) this.copyTo(it)
it.flush()
} }
return file.suspendToExternalImage() return file.suspendToExternalImage()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment