无法将ParseFile从Unity上传到Parse

时间:2015-08-29 05:04:48

标签: parse-platform unity3d

所以我设法使用facebookutils创建用户,从facebook下载数据,包括电子邮件和&用户照片。然后,我能够将电子邮件和个人资料Pic(我认为)分别映射到解析用户和parsefile。然后我尝试上传所有这些来解析,然后失败。当我评论出图片代码时,我能够更新电子邮件,所以很明显问题出在图片上。以下是与下载,处理和处理相关的所有代码片段。上传图片。我上传时遇到的具体错误是:

FormatException:输入字符串的格式不正确

这些文件并不是特别透彻,所以我自己也得到了以下内容......但我怀疑我做错了什么......我已经放置了#34;评论&# 34;在每一行旁边,所以我的目的很清楚我试图做的事情。

哦,我在Unity中这样做,我希望有人可以提供帮助

        Dictionary<string, string> url = new Dictionary<string, string>() {{"picture", "picture"}};

        FB.API("me?fields=picture.height(200)", Facebook.HttpMethod.GET, FetchProfilePic, url);

    JSONNode resultData = JSON.Parse (result.Text);   //here i receive the image data in JSON
    urlme = resultData ["picture"] ["data"] ["url"];  // here i'm just parsing it
     imageLink = new WWW(urlme);                      // here i'm just setting it as a url

    yield return imageLink;                           // this returns an object with the image


    byte [] profileData = imageLink.bytes;            // assigning the data of the object to a byte[] object
    ParseFile profilePicFile = new ParseFile( "profilePic.jpg", profileData);   // creating a parsefile object & inserting the byte object

    Task saveProfilePic = profilePicFile.SaveAsync(); // sending the parsefile to parse
    yield return saveProfilePic;                      // waiting for the operation to complete

    user["Profile_Pic"] = profilePicFile;           // assigning the parsefile to the user with a key (this key is a new column)
    Task updateUser = user.SaveAsync();             // sending the updated user to parse

1 个答案:

答案 0 :(得分:0)

替换

byte [] profileData = imageLink.bytes;    

通过

if(imageLink.error == null)
{
    Texture2D profilePic = imageLink.texture;
    if(profilePic != null)
    {
        Byte[] bytes = profilePic.EncodeToPNG();
        // write code for creating parse file from bytes here.
    }
}