mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-09 01:30:17 +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)
|
||||
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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user