diff --git a/app/src/main/java/org/yameida/worktool/utils/HttpUtil.kt b/app/src/main/java/org/yameida/worktool/utils/HttpUtil.kt index 9cb7a9c..358f34d 100644 --- a/app/src/main/java/org/yameida/worktool/utils/HttpUtil.kt +++ b/app/src/main/java/org/yameida/worktool/utils/HttpUtil.kt @@ -112,6 +112,13 @@ object HttpUtil { * 推送图片 */ fun pushImage(url: String, titleList: List, receivedName: String?, imagePath: String, roomType: Int) { + return pushImage(url, titleList, receivedName, File(imagePath).readBytes(), roomType) + } + + /** + * 推送图片 + */ + fun pushImage(url: String, titleList: List, receivedName: String?, byteArray: ByteArray, roomType: Int) { val json = JSONObject() if (receivedName != null) { json.put("receivedName", receivedName) @@ -126,7 +133,7 @@ object HttpUtil { json.put("groupName", null) json.put("groupRemark", null) } - json.put("image", EncodeUtils.base64Encode2String(File(imagePath).readBytes())) + json.put("image", EncodeUtils.base64Encode2String(byteArray)) json.put("robotId", Constant.robotId) json.put("roomType", roomType) json.put("atMe", false) @@ -135,14 +142,14 @@ object HttpUtil { .upJson(json) .execute(object : StringCallback() { override fun onSuccess(response: Response) { - LogUtils.d("推送图片成功: ${titleList.joinToString()} $receivedName $imagePath") - log("推送图片成功: ${titleList.joinToString()} $receivedName $imagePath") + LogUtils.d("推送图片成功: ${titleList.joinToString()} $receivedName") + log("推送图片成功: ${titleList.joinToString()} $receivedName") } override fun onError(response: Response) { ToastUtils.showLong("推送图片失败") LogUtils.e("推送图片失败") - error("推送图片失败: $${titleList.joinToString()} $receivedName $imagePath") + error("推送图片失败: $${titleList.joinToString()} $receivedName") } }) }