我使用下面的代碼保存如何使用ParseFile正確檢索圖像?
ParseFile file = null;
if (ProfileImage != null && ProfileImage.ContentLength > 0 && !string.IsNullOrEmpty(ProfileImage.FileName))
{
byte[] fileBytes = new byte[ProfileImage.ContentLength];
file = new ParseFile(ProfileImage.FileName, fileBytes);
await file.SaveAsync();
var player = new ParseObject("Player");
if(file != null)
{
player["ProfilePic"] = file;
}
await player.SaveAsync();
}
我試圖檢索圖片,因此我可以顯示使用下面的代碼
ParseObject player = Task.Run(() =>
ParseObject.GetQuery("Player").WhereEqualTo("objectId", id).FirstOrDefaultAsync()).Result;
ParseFile profileImage = null;
string profileImageUrl = "";
if (player.ContainsKey("ProfilePic"))
{
profileImage = player.Get<ParseFile>("ProfilePic");
profileImageUrl = profileImage.Url.AbsoluteUri;
}
profileImageUrl有一個正確的URL,如圖像http://files.parsetfss.com/c8db8833-b04b-4877-8040-b70df1ec216c/tfss-11c442f3-6146-4316-a6c0-7c9a063d897e-Koala.jpg
但是,圖像始終被破壞。我試圖用html標籤來顯示圖像,並且圖像總是被打破。
與論壇網站不同,我們不使用「謝謝」或「任何幫助表示讚賞」,或在[so]上簽名。請參閱「[應該'嗨','謝謝',標語和致敬從帖子中刪除?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be –