Titanium Tianium JS:无法在TiSocial模块中使用存储在SQLite数据库中的图像

Titanium Tianium JS:无法在TiSocial模块中使用存储在SQLite数据库中的图像,titanium,appcelerator,titanium-alloy,Titanium,Appcelerator,Titanium Alloy,我的应用程序在本地SQLite数据库中以blob的形式存储了一组图像。这些图像是通过设备摄像头拍摄的。我使用的是钛合金,因此图像是使用合金模型的.save()方法保存的 我已经开始使用可以将图像发布到Twitter或Facebook的。它的一个参数是image,它必须是: 要共享的映像的本地/远程路径 我要使用的图像被设置为ImageView上的image属性。ImageView图像的设置如下:$。theImageView.image=args.The_图像,其中args.image是从数据库集

我的应用程序在本地SQLite数据库中以blob的形式存储了一组图像。这些图像是通过设备摄像头拍摄的。我使用的是钛合金,因此图像是使用合金模型的
.save()
方法保存的

我已经开始使用可以将图像发布到Twitter或Facebook的。它的一个参数是
image
,它必须是:

要共享的映像的本地/远程路径

我要使用的图像被设置为ImageView上的image属性。ImageView图像的设置如下:
$。theImageView.image=args.The_图像
,其中
args.image
是从数据库集合中获取的图像blob

我尝试将此图像块设置为初始化方法中的图像:

Social.activityView({
    text: "Hello world! Take a look at this: " + args.name,
    image: args.the_image,
    removeIcons:"airdrop,print,copy,contact,camera"
});
或者,我尝试使用ImageView上保存的图像,如下所示:

Social.activityView({
    text: "Hello world! Take a look at this: " + args.name,
    image: $.theImageView.image,
    removeIcons:"airdrop,print,copy,contact,camera"
});
但是这两种方法都不起作用,Tweet或Facebook消息对话框中也没有显示任何图像。控制台中不会出现任何错误

另一方面,如果我将
image
属性设置为保存在
assets
文件夹中的图像,那么它工作正常。例如:

`image: "an_image.jpg"`

我尝试了下面评论中提到的一种解决方案,即将映像保存到Ti.FileSystem,然后从那里读取映像。但是,这仍然不起作用。

然后我建议在数据库表中添加一个名为img_path的字段,因为您无法从blob中获取路径,所以当您将任何blob存储到alloy模型时,还可以将其路径添加到该模型中,以便以后可以检索并共享


希望您能理解。

我运气不错,将文件保存到Ti.Filesystem,然后检索它并使用
.getNativePath()
方法:

function getImage() {
    var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, args.alloy_id + '.jpg');  
    return f.read();  
 }

var theImage = getImage();

Social.activityView({
    text: "Just tried this beer called " + args.name,
    image: theImage.getNativePath(),
    removeIcons:"airdrop,print,copy,contact,camera"
});

您可以尝试以这种方式共享远程图像

var largeImg = Ti.UI.createImageView({
        width : Ti.UI.SIZE,
        height : 'auto',
        image :'http://www.google.com/doodle4google/images/splashes/featured.png'
    });

var imageGoogle =largeImg.toBlob();

// share image
Social.activityView({
    status : "Hello world! Take a look at this: ",
    image : imageGoogle,
    removeIcons:"airdrop,print,copy,contact,camera"
});

将任何blob存储到模型时,如何为图像添加路径?请记住这些图像是用照相机拍摄的。哦……那么你应该在你的问题中描述这一点,这样我们就可以知道你实际上是在存储照相机拍摄的水滴图像。所以我建议将图像存储在applicationDataDirectory中,并在model中只存储图像名称,以便您可以将其取回。好的,谢谢Mitul Bhalia,我已经更新了我的问题。可以编辑您的问题并给出您想法的示例吗?我只想说,首先使用Ti.Filesystem对象将blob保存在applicationDataDirectory中。例如,假设图像名称为test.png,然后使用该名称将图像存储在dataDirectory中,然后使用该图像名称将图像存储在模型中。。。因此,稍后您可以使用模型中的test.png获取该图像,并使用Ti.Filesystem读取该图像。这就是我试图在回答中说服您的方法。:)