我正在尝试使用 Xamarin(c#) 开发一个 android 应用程序并解析用户将捕获图片并将其上传到解析的位置。我知道如何上传文本文件,但由于我是新手,所以我不知道如何处理图像文件,谁能帮忙。这就是我上传文本文件的方式
byte[] data = System.Text.Encoding.UTF8.GetBytes("This is content of the text file");
ParseFile file = new ParseFile("resume.txt", data);
await file.SaveAsync();
ParseObject gameScore = new ParseObject("GameScore");
gameScore["score"] = 0001;
gameScore["playerName"] = " Bob";
gameScore["e"] = file;
await gameScore.SaveAsync();`
谁能帮我解决这个问题..谢谢。
最佳答案
Parse 有一个完整的 section of docs致力于处理文件。
// File is in System.IO
byte[] data = File.ReadAllBytes(path_to_your_image);
ParseFile file = new ParseFile(name_of_your_file, data);
await file.SaveAsync();
// link your file object to your Parse object
gameScore["image"] = file;
更新:
文档特别说
It's important that you give a name to the file that has a file extension. This lets Parse figure out the file type and handle it accordingly. So, if you're storing PNG images, make sure your filename ends with .png.
关于c# - 上传捕获的图像进行解析(解析对象),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24375391/