Titanium 我可以将用户的照片设置为钛ACS吗?

Titanium 我可以将用户的照片设置为钛ACS吗?,titanium,appcelerator,titanium-mobile,acs,Titanium,Appcelerator,Titanium Mobile,Acs,我需要向我的用户添加一张照片,通过从web界面添加,我将照片设置为一个名为photo的字段,但是如果我尝试从移动应用程序以编程方式执行相同的操作,它将不起作用 photonativePath是相机或图库中的照片url Cloud.Users.update({ email: 'joeuser@mycompany.com', first_name: 'joe', last_name: 'user', photo : Titanium.Filesystem.getFil

我需要向我的用户添加一张照片,通过从web界面添加,我将照片设置为一个名为photo的字段,但是如果我尝试从移动应用程序以编程方式执行相同的操作,它将不起作用


photonativePath是相机或图库中的照片url

Cloud.Users.update({
    email: 'joeuser@mycompany.com',
    first_name: 'joe',
    last_name: 'user',
    photo : Titanium.Filesystem.getFile(photonativePath),
    custom_fields: {
        favorite_color: 'blue',
        age: 25
    }
}, function (e) {
    if (e.success) {
        var user = e.users[0];
        alert('Success:\n' +
            'id: ' + user.id + '\n' +
            'first name: ' + user.first_name + '\n' +
            'last name: ' + user.last_name);
    } else {
        alert('Error:\n' +
            ((e.error && e.message) || JSON.stringify(e)));
    }
});
试试下面的方法, 您可以使用openPhotoGallery方法打开photoGallery。这将从库中打开图像并选择图片。它将在成功回调中更新图片

function openPhotoGallery(){
    Ti.Media.openPhotoGallery({
        success: function (event){
            var image=event.media;
            var imgvwTest = Ti.UI.createImageView({
                image : image
            });
            updatePhoto(imgvwTest.toImage());
        },
        cancel:function(){
            Titanium.UI.createAlertDialog({
                title:'Error', 
                message:'An error occured while trying to reference your gallery!'
            }).show();
        },
        error:function(er){
            Titanium.UI.createAlertDialog({
                title:'Error', 
                message:'An error occured while trying to reference your gallery!'
            }).show();
        }
    });

}

function updatePhoto(selectedImage){

    Cloud.Users.update({
        email: 'joeuser@mycompany.com',
        first_name: 'joe',
        last_name: 'user',
        photo : selectedImage.media,
        custom_fields: {
            favorite_color: 'blue',
            age: 25
        }
    }, function (e) {
        if (e.success) {
            var user = e.users[0];
            alert('Success:\n' +
                'id: ' + user.id + '\n' +
                'first name: ' + user.first_name + '\n' +
                'last name: ' + user.last_name);
        } else {
            alert('Error:\n' +
                ((e.error && e.message) || JSON.stringify(e)));
        }
    });
}

如果您有任何问题,请告诉我

您遇到了什么错误?PhotonativePath的值是多少PhotonativePath是来自照相机或多媒体资料的我的照片url。不起作用,i'v success但照片尚未设置您是否在ACS服务器中检查了照片?那里有吗?好的,同样的代码对我有用!!!是否可以尝试使用SelecteImage.media而不是updatePhoto方法中的SelecteImage?