【问题标题】:Conversion of TiBlob Object to StringTiBlob 对象到字符串的转换
【发布时间】:2012-08-13 09:45:51
【问题描述】:

我需要将 TiBlob 图像对象转换为字符串。我尝试了以下方法。但没有成功。

var imageFile = Titanium.Filesystem.getFile('images8.png');
var oneImage = imageFile.read();
var image = oneImage;
var tempFile = Titanium.Filesystem.createTempFile();
tempFile.write(oneImage);
var contents = tempFile.read();
var x = Ti.Utils.base64decode(contents);

alert('type of x is '+typeof(x));  //Object
alert('type of x is '+x.text);   //null
alert(JSON.stringify(oneImage));  //output is null
alert('value of image is '+image);  //TiBlob Object
alert(typeof(contents.toString()));    //String
alert('value of image after conversion is '+contents.toString()); //null
alert('value of text image is '+typeof(contents.text));  //String
alert('value of image after conversion text is '+contents.text);  //null

提前致谢...........

【问题讨论】:

    标签: mobile camera titanium blob appcelerator-mobile


    【解决方案1】:

    你不应该打电话给Ti.Utils.base64Decode,你应该打电话给Ti.Utils.base64encode

    Decode 将 previously base64 编码的字符串转换为非 base64 字符串。如果您想将此图像传递到服务器或任何类似性质的东西,编码就是您要查找的内容。

    【讨论】:

    • 尝试跳过临时目录的内容,直接转到var x = Ti.Utils.base64decode(oneImage);
    猜你喜欢
    • 1970-01-01
    • 2014-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-17
    • 2012-04-06
    • 2014-03-17
    • 1970-01-01
    相关资源
    最近更新 更多