Unified Image suffix: .mirai

This commit is contained in:
Him188 2020-04-23 20:37:01 +08:00
parent 5ad5c17a60
commit 437f9db575
2 changed files with 6 additions and 5 deletions

View File

@ -91,7 +91,7 @@ internal class FriendImpl(
fileId = 0,
fileMd5 = image.md5,
fileSize = image.inputSize.toInt(),
fileName = image.md5.toUHexString("") + ".gif",
fileName = image.md5.toUHexString("") + "." + ExternalImage.defaultFormatName,
imgOriginal = 1
)
).sendAndExpect<LongConn.OffPicUp.Response>()

View File

@ -67,12 +67,15 @@ class ExternalImage private constructor(
}
companion object {
const val defaultFormatName = "mirai"
fun generateUUID(md5: ByteArray): String {
return "${md5[0, 3]}-${md5[4, 5]}-${md5[6, 7]}-${md5[8, 9]}-${md5[10, 15]}"
}
fun generateImageId(md5: ByteArray): String {
return """{${generateUUID(md5)}}.gif"""
return """{${generateUUID(md5)}}.$defaultFormatName"""
}
}
@ -90,9 +93,7 @@ class ExternalImage private constructor(
override fun toString(): String = "[ExternalImage(${generateUUID(md5)})]"
fun calculateImageResourceId(): String {
return "{${generateUUID(md5)}}.gif"
}
fun calculateImageResourceId(): String = generateImageId(md5)
}
/**