简体   繁体   English

worklight从mysql获取图像Blob

[英]worklight get image blob from mysql

I'm new to worklight, and i'm trying to get an image which is stored in mysql as a blob data. 我是worklight的新手,我正在尝试获取作为blob数据存储在mysql中的图像。 but i'm having trouble the picture won't show. 但我有麻烦,图片无法显示。 here is my code 这是我的代码

WL.Client.invokeProcedure(invocationData, {
  onSuccess: function(response){
    var result = response.invocationResult; //ini hasilnya
    if(result.isSuccessful){
      var data = result.resultSet;
      var text ='';
      $.each(data , function(index,item){
        var base64blob = item.picture;
        var image = document.createElement('img');
                image.src = 'data:image/png;base64,'+ base64blob;
                document.body.appendChild(image);
                ...
        text += '<img class="ui-li-thumb" src="' + 'data:image/jpg;base64,'+ base64blob + '"></img>';
        ...
  });
  $('#order_list').html(text);
        $('#order_list').listview('refresh');
    } else{
            alert("error");
    }

Adapters returns only a JSON object. 适配器仅返回JSON对象。
A BLOB is a binary large object. BLOB是二进制大对象。
You need to convert the binary object to base64 before it is sent as the response. 您需要先将二进制对象转换为base64,然后再将其作为响应发送。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM