-1

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)

The questions are:

  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)

  2. 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)

double-beep
  • 5,031
  • 17
  • 33
  • 41
Bodega Pangal
  • 141
  • 3
  • 15
  • 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. – Jason Nov 06 '18 at 13:26
  • Regarding how to access my file manager in DROID and IOS that suggests? @Jason – Bodega Pangal Nov 06 '18 at 13:28
  • https://github.com/Studyxnet/FilePicker-Plugin-for-Xamarin-and-Windows – Jason Nov 06 '18 at 13:32
  • You have already answered my two questions, I should propose an answer @Jason – Bodega Pangal Nov 06 '18 at 13:34
  • You should first turn your file into a byte[] and then use MultiPartDataFormContent to upload it. This is answered in this question https://stackoverflow.com/questions/20319886/http-multipartformdatacontent – Axemasta Nov 06 '18 at 17:30

1 Answers1

3

There is a File Picker plugin for Xamarin

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.

Jason
  • 86,222
  • 15
  • 131
  • 146