如何在Xamarin.Forms中上传文件? [英] How to upload a file in Xamarin.Forms?

查看:94
本文介绍了如何在Xamarin.Forms中上传文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过Xamarin Forms中带有 POST 方法的通信API通过通讯API上传 .PDF 和/或 .JPG 文件.NET标准.为此,我将得到一个可以打开相机和图库的插件的支持,在这种情况下,我将使用 Xam.Plugin.Media ,但对于PDF,则无法打开该文件的文件管理器.手机(保存文件的地方)

I need to upload a .PDF and/or .JPG file through a communication API with a POST method from Xamarin Forms with .NET Standard. For this I will be supported by a plugin that can open the camera and the gallery in this case I occupy Xam.Plugin.Media, but in the case of PDFs I can not open the file manager of the phone (where the files are saved)

问题是:

  1. 在什么插件中我可以帮助发送PDF文件?(这允许用户从文件管理器中选择与操作系统无关的文件)

  1. In what plugin can I help to send PDF files? (That allows the user to select a file from the file manager independent of the operating system)

要通过API REST发送PDF文件,我需要将其转换为字节数组吗?(在摄影方面,我也这样做)

To send the PDF file through the API REST, do I need to transform it to an array of bytes? (I do the same in the case of photography)

推荐答案

有一个 File.ReadAllBytes()将以字节[]形式返回任何文件的内容.您需要通过阅读文档或询问开发人员来确定您的API是否需要这样做.

File.ReadAllBytes() will return the contents of any file as a byte[]. Whether or not this is required by your API is something you need to determine by reading the docs or asking the developer.

这篇关于如何在Xamarin.Forms中上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆