Upload File from Xamarin app to ASP.NET server
Why Stack Overflow recommends it
Stack Overflow users link it as the tutorial they followed for Xamarin file uploads, usually when they hit errors in the same code (ApiController, async HttpClient calls, camera and storage permissions).
Recommended by 1 people across 1 different months, 2017 to 2020.
What it is
A 35-minute tutorial by Houssem Dellai showing how to upload a file from a Xamarin.Forms mobile app to an ASP.NET Web API server. It walks through picking or taking a photo with the Media plugin and posting it as multipart form data to a controller endpoint.
What people said
Recommends Fish1996 · 2020-03 · Stack Overflow · on “VS Xamarin.Forms (Android): Camera and Storage access denied with Xam.Plugin.Media”
I have an Xamarin.Forms app, which I test for Android 10 (on device) at the moment. I want to have two buttons: pick photo (from storage) and take photo (from camera). I had some problems with not having the permissions to access the storage and the camera, so I followed this tutorial: [this video] . This tutorial is everything I need, since these two buttons are discussed here. I'm using Xam.Plugin.Media for this project. Also with this tutorial I'm having trouble with getting permissions to my camera and my storage. The error is constantly the same: 'Camera permission(s) are required.' or: 'Storage permission(s) are required.' I did add the permissions to AndroidManifest.xml: <?xml version="1.0
Cites user8393563 · 2017-08 · Stack Overflow · on “Upload recently taken Image from Android/iOS (Crossplatform xamarin.forms) with MediaPlugin on IIS”
currently I'm stuck on uploading the images which I took within my app on my own asp.net webserver. I used the Media.Plugin from James Montemagno. Taking the image works fine. The problem: I'm getting a unhandled exception when uploading the image. In my solution I created a new WebApplication as referenced in the youtube tutorial [this video] ! I did almost everything like him. Here is my WebApplication Code: public async Task<string> Post() { try { var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; var fileName = "test.png"; // postedFile.FileName.Split('\\').LastOrDefault().Spl
Cites Shi Jie Tio · 2018-03 · Stack Overflow · on “ApiController could not be found”
Based on this video [this video] I have add the using System.Web; using System.Web.Http; but i still get the error state that apicontroller could no found, and so on, below picture is the error I face: [LINK] below is my code : using System; using System.Linq; using System.Threading.Tasks; using System.Web; using System.Web.Http; using System.Collections.Generic; namespace UploadToServer.Server.Controllers { public class UploadsController : ApiController { [Route("api/Files/Upload")] public async Task<string> Post() { try { var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; var fi
Cites Shi Jie Tio · 2018-03 · Stack Overflow · on “Task does not contain a definition for Content”
How to overcome the error below? I have follow below tutorial but I get the red line that state that does not contain definition of Content . [this video] private void UploadFile_Cliked(object sender, EventArgs e) { var content = new MultipartFormDataContent(); content.Add(new StreamContent(_mediaFile.GetStream()), "\"file\"", $"\"{_mediaFile.Path}\""); var httpClient = new HttpClient(); var uploadServiceBaseAddress = " [LINK] "; var httpResponseMessage = httpClient.PostAsync(uploadServiceBaseAddress, content); RemotePathLabel.Text = httpResponseMessage.Content.ReadAsStringAsync(); } [LINK] 'Task' does not contain a definition for 'Content' and no extension method 'Content' accepting a first argu
Cites Reyhan Manuel · 2019-12 · Stack Overflow · on “I can't show a file path when click upload button”
I followed the video tutorial Houssem Dellai about Upload File from Xamarin app to ASP.NET server on youtube. here is the link [this video] My problem when i click button upload photo my code is only executed until var httpResponseMessage = await httpclient.PostAsync(uploadServiceBaseAddress, content); And didn't show message error, my code cannot executed RemotePathFile.Text for show path file This is my coding private async void UploadFile_Clicked(object sender, EventArgs e) { var content = new MultipartFormDataContent(); content.Add(new StreamContent(_mediaFile.GetStream()), "\"file\"", $"\"{_mediaFile.Path}\""); var httpclient = new HttpClient(); var uploadServiceBaseAddress = " [LINK] "; var