2015-12-21 55 views
0

我在從手機圖庫到parse.com數據庫的imageview中上傳圖像時遇到問題。解析說文件限制是10MB。任何人都可以告訴我我做錯了什麼?Parse.com不保存大於400KB的圖像

ParseFile imgFile = new ParseFile(fullName+"_"+emp+".jpeg", bite_image); 
imgFile.saveInBackground(); 

ParseObject teamTable = new ParseObject("TeamsTable"); 
teamTable.put("Team", team); 
teamTable.put("Name", fullName); 
teamTable.put("images", imgFile); 
teamTable.saveInBackground(new SaveCallback() { 

@Override 
public void done(ParseException e) { 
    if (e == null) { 
     startActivity(new Intent(RegisterForm.this, Login.class)); 
     Toast.makeText(getApplicationContext(), "Successful Registration!", Toast.LENGTH_LONG).show(); 
     finish(); 


    } else { 
    } 
    } 
    }); 
+0

你得到的錯誤是什麼?您也不需要單獨上傳文件,保存對象時可以一步完成。 –

+0

將ParseObject保存放在ParseFile saveInBackground的回調函數的done()方法中,這將確保您的圖像在保存完整對象之前保存在Parse中。 – TheTool

+0

@TheTool我也將ParseFile和ParseObject保存在AsyncTask中。爲什麼onPostExecute()在ParseObject saveInBackground完成之前執行? –

回答

0

您應該首先保存包含圖像的PFFile,然後將此PFFile添加到您的對象。

PFFile *file = [PFFile fileWithName:@"image.jpg" data:UIImageJPEGRepresentation(image,1.)]; 
[file saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) { 
    if (succeeded) { 
     // Add the file to your object and save your object