react-native-wechat-share
Advanced tools
@@ -77,11 +77,11 @@ package com.wechatshare | ||
| // 2. 读取图片字节数据(关键修改) | ||
| var imageBytes: ByteArray | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| try { | ||
| val imageBytes: ByteArray = try { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| Files.readAllBytes(imageFile.toPath()) | ||
| } catch (e: Exception) { | ||
| } else { | ||
| FileInputStream(imageFile).use { it.readBytes() } | ||
| } | ||
| } else { | ||
| FileInputStream(imageFile).use { it.readBytes() } | ||
| } catch (e: Exception) { | ||
| promise.reject("READ_FAILED", "读取图片失败: ${e.message}") | ||
| return | ||
| } | ||
@@ -96,3 +96,3 @@ | ||
| FileOutputStream(externalFile).use { it.write(imageBytes) } | ||
| imagePath = externalFile.absolutePath | ||
| imageObj.imagePath = externalFile.absolutePath | ||
| } catch (e: Exception) { | ||
@@ -103,12 +103,2 @@ promise.reject("COPY_FAILED", "保存临时图片失败: ${e.message}") | ||
| } else { | ||
| imageBytes = try { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| Files.readAllBytes(imageFile.toPath()) | ||
| } else { | ||
| FileInputStream(imageFile).use { it.readBytes() } | ||
| } | ||
| } catch (e: Exception) { | ||
| promise.reject("READ_FAILED", "读取图片失败: ${e.message}") | ||
| return | ||
| } | ||
| imageObj.imageData = imageBytes | ||
@@ -115,0 +105,0 @@ } |
+1
-1
| { | ||
| "name": "react-native-wechat-share", | ||
| "version": "0.1.36", | ||
| "version": "0.1.37", | ||
| "description": "react-native wechat share", | ||
@@ -5,0 +5,0 @@ "main": "./lib/module/index.js", |
15384953
0