c# - 上传捕获的图像进行解析(解析对象)

标签 c# android xamarin parse-platform

我正在尝试使用 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/

相关文章:

c# - Azure DevOps YAML 管道失败并显示 "A sequence was not expected"

c# - 如果您被迫使用 Anemic 域模型,您将业务逻辑和计算字段放在哪里?

java - Android Recycler View "onBindViewHolder"函数 "static method cannot be called from non-static method"中的问题

android - 使用 AsyncTask 序列化执行多个 fragment

c# - Xamarin 使用 FontAwesome 创建自定义按钮

c# - 在 C# 中创建简单的嵌入式 http 和 https 应用程序

c# - 在 if 语句中使用 'if (variable == true)' 与 'if (variable)' 有什么不同吗?

android - 如何忽略用于改造的模型中的某些变量

c# - xamarin 中构建的 Android 后台位置正在永远占用

image - 使用 SkiaSharp 翻转 SKPath