mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-09 18:00:33 +08:00
Add pre-condition check
This commit is contained in:
parent
90ef83e345
commit
04b0287738
@ -116,7 +116,7 @@ suspend fun InputStream.uploadAsImage(contact: Contact): OfflineImage =
|
|||||||
*/
|
*/
|
||||||
@Throws(OverFileSizeMaxException::class)
|
@Throws(OverFileSizeMaxException::class)
|
||||||
suspend fun File.uploadAsImage(contact: Contact): OfflineImage {
|
suspend fun File.uploadAsImage(contact: Contact): OfflineImage {
|
||||||
require(this.exists() && this.canRead())
|
require(this.isFile && this.exists() && this.canRead()) { "file ${this.path} is not readable" }
|
||||||
return withContext(Dispatchers.IO) { toExternalImage() }.upload(contact)
|
return withContext(Dispatchers.IO) { toExternalImage() }.upload(contact)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user