Closed codiri closed 5 months ago
Is there any update about this issue ?!!
@codifius did you find any solution for this issue?
Fix ImageEditorModule.java
import java.io.ByteArrayInputStream;
import java.util.Base64;
...
private InputStream openBitmapInputStream() throws IOException {
InputStream stream;
if(mUri.startsWith("data:")) {
Base64.Decoder decoder = Base64.getMimeDecoder();
stream = new ByteArrayInputStream(decoder.decode(mUri.substring(mUri.indexOf(",") + 1)));
}
else if (isLocalUri(mUri)) {
stream = mContext.getContentResolver().openInputStream(Uri.parse(mUri));
} else {
URLConnection connection = new URL(mUri).openConnection();
stream = connection.getInputStream();
}
if (stream == null) {
throw new IOException("Cannot open bitmap: " + mUri);
}
return stream;
}
...
then use patch-package
diff --git a/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java b/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java
index c053ab4..beca818 100644
--- a/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java
+++ b/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java
@@ -13,11 +13,13 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
+import java.util.Base64;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -243,7 +245,11 @@ public class ImageEditorModule extends ReactContextBaseJavaModule {
private InputStream openBitmapInputStream() throws IOException {
InputStream stream;
- if (isLocalUri(mUri)) {
+ if(mUri.startsWith("data:")) {
+ Base64.Decoder decoder = Base64.getMimeDecoder();
+ stream = new ByteArrayInputStream(decoder.decode(mUri.substring(mUri.indexOf(",") + 1)));
+ }
+ else if (isLocalUri(mUri)) {
stream = mContext.getContentResolver().openInputStream(Uri.parse(mUri));
} else {
URLConnection connection = new URL(mUri).openConnection();
@Hot-key solution worked to me!
Summary
👋 Hi!
When i am using base64 uri with cropImage function it works perfectly with IOS but in Android i have this issue:
Environment info
Reproduce the issue