私はappcelerator titanium(sdk 1.6.2)を使用してモバイル(iphone /アンドロイド)アプリケーションを開発しています。 アプリ内の特定のポイントで、ユーザーはimageViewに表示される画像を選択し、ベース64でエンコーディングしてから、自分のサーバーにアップロードします。 問題は、フォトギャラリーの成功イベントが、選択されたイメージをBLOBオブジェクトとして返し、Titanium.Utils.base64encodeメソッドが文字列値のみを受け入れることです。 Titanium.Blobオブジェクトを文字列に変換する方法はありますか?ここでappceleratorチタンベース64エンコードブロブオブジェクト
は、コードスニペットです:
var imageView = Titanium.UI.createImageView({
height:200,
width:200,
top:20,
left:10,
backgroundColor:'#999'
});
Titanium.Media.openPhotoGallery({
success:function(event)
{
var cropRect = event.cropRect;
var image = event.media;//blob object
// set image view
Ti.API.debug('Our type was: '+event.mediaType);
if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
{
imageView.image = image;// this works
var imgStr=Ti.Utils.base64encode(image);// doesn't work because 'image' has to be a string!, but how?
}
else
{
}
Titanium.API.info('PHOTO GALLERY SUCCESS cropRect.x ' + cropRect.x + ' cropRect.y ' + cropRect.y + ' cropRect.height ' + cropRect.height + ' cropRect.width ' + cropRect.width);
},
allowEditing:true,
popoverView:popoverView,
arrowDirection:arrowDirection,
mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
});
は