Xamarin Uploading Photos and Videos to the Server

Hello. In today’s writing, we will talk about a topic that is on almost every major project. If you want to upload photos to our application or choose to interact with other users online after you select a photo, we need to store it in a server or database. We can do this using the API. In this writing we will do them.

First we need to write a web service. For this I will create an ASP.NET MVC project. We need to pay attention here; Note that the Web API option must be selected from the options that come up while creating the project. Then create the project. Actually, the process is very simple. We will write a few lines of code. In our project, we need to create a class by overriding the Controllers folder. Let’s put the name of this class in UploadController. You can change it as you like. This class must inherit from the ApiController class. We have to make an orientation later. With this orientation, the field will be added to the end of your step. For instance, take the domain step sezeromer.com if you need to. If I make a redirect here, it will be sezeromer.com/api/Files/Upload. When I enter this address, the function in this class will work. Then I write my codes. The other issue that needs to be taken care of here is where we are going to record our photos or videos. I specified here as the uploads folder. So I’m adding a folder called uploads to the project one by one.

Actually, our service is that easy. If you like this service you can stay in Azure or use it locally. After that, on the Xamarin side. I use the Xaml.Media.plugin plugin to select or draw photos in the Xamarin.Forms project. You can use whatever you want, provided it is in the MediaFile type.

To send data to our Web service, we need to create a content. After creating the content, we put the photo and the path of our photo into it. To send this content to adrese, we need to create a Client. After creating the client, we need to specify the address. We need to specify which address it is. I have mentioned above You have to write your forwarding address if you have forwarded your address since you wrote it. We send the content we created as the last transaction with the client we have created. That’s our process.

If you encounter a problem, you can reach it by comment or mail.

 

3 thoughts on “Xamarin Uploading Photos and Videos to the Server

  1. how to do it xamarin forms c#. i use it in my project but the request is succeed and the file doesn’t stored in server. And where i find the api controller.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.