Java Base64编码图像未在Cordova中显示

Java Base64编码图像未在Cordova中显示,java,javascript,angularjs,ionic-framework,cordova-plugins,Java,Javascript,Angularjs,Ionic Framework,Cordova Plugins,将图像作为Base64数据添加到我的视图不适用于此imagepicker 我在Cordova应用程序中使用带angular的Ionic。cordova应用程序是使用人行横道构建的。在我的应用程序中,您可以向对象添加图像。这可以通过相机或图像选择器来完成 相机返回base64编码的图像数据,该数据工作正常,但图像选择器不返回 是原始文件的分支,因此它返回base64编码的数据,而不是文件uri。可以找到插件返回的图像数据示例 问题是,当我将图像提交到服务器(作为base64)并检索它(服务器解码图

将图像作为Base64数据添加到我的视图不适用于此imagepicker

我在Cordova应用程序中使用带angular的Ionic。cordova应用程序是使用人行横道构建的。在我的应用程序中,您可以向对象添加图像。这可以通过相机或图像选择器来完成

相机返回base64编码的图像数据,该数据工作正常,但图像选择器不返回

是原始文件的分支,因此它返回base64编码的数据,而不是文件uri。可以找到插件返回的图像数据示例

问题是,当我将图像提交到服务器(作为base64)并检索它(服务器解码图像数据,然后将其存储在文件中,然后再次将数据作为base64返回)时,图像工作正常。这可以在不刷新页面的情况下完成

返回数据的方法(可能以cordova无法处理的方式返回base64?)

activityresult上的公共void(int-requestCode、int-resultCode、Intent-data){
if(resultCode==Activity.RESULT\u OK&&data!=null){
ArrayList文件名=data.getStringArrayListExtra(“多文件名”);
ArrayList encodedImages=新的ArrayList();
for(字符串文件名:文件名){
试一试{
urifileuri=Uri.parse(文件名);
InputStream InputStream=新文件InputStream(fileUri.getPath());
字节[]字节;
字节[]缓冲区=新字节[20000000];//字节[8192]
int字节读取;
ByteArrayOutputStream输出=新建ByteArrayOutputStream();
试一试{
而((bytesRead=inputStream.read(缓冲区))!=-1){
输出写入(缓冲区,0,字节读取);
}
}捕获(IOE异常){
e、 printStackTrace();
}
字节=输出。toByteArray();
字符串encodedString=Base64.encodeToString(字节,Base64.NO_WRAP);
encodedImage.add(encodedString);
}捕获(FileNotFoundException fnfe){
}
}
JSONArray res=新的JSONArray(encodedImages);
这个.callbackContext.success(res);
}else if(resultCode==Activity.RESULT\u已取消){
JSONArray res=新的JSONArray();
这个.callbackContext.success(res);
}否则{
this.callbackContext.error(“未选择图像”);
}
}

foto视图(部分,包括ng在内)和其他图像工作良好,因此这可能是好的

<ion-scroll direction="x" scrollbar-y="false" has-bouncing="true">
<div style="width: {{(vehicle.photos().length * 212) + 250}}px;" class="padding">
    <button class="button icon ion-ios7-plus-outline button-outline button-positive button-large" style="width: 200px; height: 200px;" ng-click="galleryCameraDialog()"></button>
        <img  ng-repeat="image in vehicle.photos()" style="margin-right: 5px; background-image: url(data:{{images[image].filetype()}};base64,{{images[image].data()}});background-repeat: no-repeat; background-position: center center; background-size: cover;" height="200" width="200" ng-click="removeDialog(image)">
</div></ion-scroll>


如果需要,请要求提供更多信息,结构相当复杂

为什么要发送JsonArray,可以使用success方法直接发送图像字符串。

因为可以选择多个图像。
<ion-scroll direction="x" scrollbar-y="false" has-bouncing="true">
<div style="width: {{(vehicle.photos().length * 212) + 250}}px;" class="padding">
    <button class="button icon ion-ios7-plus-outline button-outline button-positive button-large" style="width: 200px; height: 200px;" ng-click="galleryCameraDialog()"></button>
        <img  ng-repeat="image in vehicle.photos()" style="margin-right: 5px; background-image: url(data:{{images[image].filetype()}};base64,{{images[image].data()}});background-repeat: no-repeat; background-position: center center; background-size: cover;" height="200" width="200" ng-click="removeDialog(image)">
</div></ion-scroll>