【问题标题】:Unable to upload photo using Appcelerator Cloud Services (ACS)无法使用 Appcelerator 云服务 (ACS) 上传照片
【发布时间】:2013-07-09 06:36:51
【问题描述】:

我正在尝试使用 ACS 上传照片,但我遇到了一些运行时错误。 这是我正在使用的代码:

var image;
function uploadPhoto(){
Titanium.Media.openPhotoGallery({
    success: function(e){
    //  alert(e.mediaType);
        if(e.mediaType == Ti.Media.MEDIA_TYPE_PHOTO){
           image = e.media;
           alert(image);

           Cloud.Photos.create({
                photo: Titanium.Filesystem.getFile(image)
            }, function(e){
                if(e.success){
                    var photo = e.photos[0];
                    alert('Success:\n' +
                        'id: ' + photo.id + '\n' +
                        'filename: ' + photo.filename + '\n' +
                        'size: ' + photo.size,
                        'updated_at: ' + photo.updated_at);
                }else{
                    alert('Error:\n' +
                    ((e.error && e.message) || JSON.stringify(e)));
                    alert("Code: "+e.code);
                }
            });
       }
    },
    cancel: function(){

    },
    error: function(err){
        alert("ERROR: "+err);
    },
    mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]
});
}

我在 Android 设备上运行,当我尝试上传任何图像时,我收到以下错误:

Error: Invalid photo file attachment
Code: 400

谁能告诉我解决办法?

谢谢! :)

【问题讨论】:

    标签: javascript android appcelerator titanium-mobile


    【解决方案1】:

    这一行

    photo: Titanium.Filesystem.getFile(image)
    

    应该是

    photo: image
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多