Uploading Files From a Xamarin.Forms App to ASP.NET Web API

Поділитися
Вставка
  • Опубліковано 12 жов 2024

КОМЕНТАРІ • 135

  • @jfversluis
    @jfversluis  2 роки тому

    In this video you learned how to upload files from your client app to your server app, how about uploading this files to Azure Blob Storage? Look no further: ua-cam.com/video/5fJZQcukagk/v-deo.html

  • @AldairOH
    @AldairOH 3 роки тому +1

    You are great, I met you because of Kym recommendation. Such a great video !

    • @jfversluis
      @jfversluis  3 роки тому

      Oh thank you! That is so nice of Kym! ❤️

  • @aiyaar3588
    @aiyaar3588 3 роки тому

    Hola! Man you are a King....! I am student, doing me project in Xamarin forms and your Videos help me a lot . Love from Pakistan

    • @jfversluis
      @jfversluis  3 роки тому +1

      That is wonderful to hear Omar! You'll be graduating in no-time! :D

  • @williamsknot
    @williamsknot 3 роки тому +2

    Man, i just wanna say thank you for this and others great xamarin tutorials! :D

    • @jfversluis
      @jfversluis  3 роки тому +1

      I appreciate you taking the time to tell me. That really keeps me going, thank you so much!

  • @stevensmith5626
    @stevensmith5626 2 роки тому

    You my friend are a fantastic teacher. thanks so much for making sense and being complete.

    • @jfversluis
      @jfversluis  2 роки тому

      Wow Steven, thanks for this! You made my day!

  • @udaysuddhala3512
    @udaysuddhala3512 3 роки тому

    very clear and great work from you gerald!! really loving your videos :) . thanks a lot and waiting for more.

    • @jfversluis
      @jfversluis  3 роки тому

      Many thanks Uday! Thank you for taking the time to let me know. Is there anything specific you'd want to learn?

    • @udaysuddhala3512
      @udaysuddhala3512 3 роки тому

      @@jfversluis how about pushnotification implementation in XF ? may be this topic need a series of videos ..

    • @jfversluis
      @jfversluis  3 роки тому +1

      It definitely needs a series! 😄 I am planning it though. What about: setting up 1. Azure service & getting api keys, 2. Implement Android, 3. Implement iOS, 4. Implement uwp 5. Implement server-side code ?

    • @udaysuddhala3512
      @udaysuddhala3512 3 роки тому +1

      @@jfversluis wow.. this would be great !! I am eagerly waiting ..😍👍

  • @aboubacar.traore
    @aboubacar.traore 3 роки тому +1

    You're very honeslty good. Can you please build an entire project from start to finish like this. Weather App Design in Adobe XD (Wireframe/Mockup + Prototype) - UA-cam, but by also building your own server and storing images of cities on it for the app to retrieve later.

    • @jfversluis
      @jfversluis  3 роки тому +1

      Thank you so much for your kind words! As much as I'd love to do that I'm focussing on the single concepts for now :)

  • @vijaichaudhary8092
    @vijaichaudhary8092 Рік тому

    Great Gerald , only you are champ of xamarin. Thanks alot.

    • @jfversluis
      @jfversluis  Рік тому +1

      Haha thanks Vijai! Appreciate it!

  • @aboubacar.traore
    @aboubacar.traore 3 роки тому +1

    Great video, really. I would really like a video on the server part but saving binary data in sql server table. Thanks in advance.

    • @jfversluis
      @jfversluis  3 роки тому

      I think saving binary data in an SQL server is not something you should do, it's not optimized for it, you're better off saving a filepath or URL in your database and store your file on a filesystem

  • @THE_NE0
    @THE_NE0 3 роки тому +1

    This man is the best, hes reading my mind!! Please could you make a video about inapp purchase with google and apple pay pleeeease

    • @jfversluis
      @jfversluis  3 роки тому +1

      Nice one! I'll add it, did you see this? github.com/jamesmontemagno/InAppBillingPlugin

    • @THE_NE0
      @THE_NE0 3 роки тому

      @@jfversluis yeah sow it, but very old and bad documentation

    • @jfversluis
      @jfversluis  3 роки тому +1

      @@THE_NE0 Understood, I'll see what I can do!

  • @matthewleibowitz7372
    @matthewleibowitz7372 3 роки тому

    Very nice so far!
    You can also do a copy direct to the file system:
    using var fileStream = File.Create();
    file.CopyTo(fileStream);

    • @jfversluis
      @jfversluis  3 роки тому +1

      Fantastic! I always get confused what method to use with all these streams and things... This seems a bit simpler though :D

  • @jwj4535
    @jwj4535 3 роки тому +1

    great video, I have been able to upload multimedia content to Blob Storage when using Postman using what you showed in your other video, now I only have to discover where I am facing to implement this and I will be able to upload pictures to an storage account in Azure using Xamarin Forms (:

    • @jfversluis
      @jfversluis  3 роки тому

      Woohoo that is awesome! Let me know how it goes!

    • @jwj4535
      @jwj4535 3 роки тому +1

      ​@@jfversluis I already discovered why it wasn't working, apparently, the content-type property of the file is null when it is received in the ApiController (IFormFile file in httpRequest.Form.Files) even tho the original file in Xamarin Forms has the correct content type.
      I simply changed the conditionals in the API controller that check the value of the content type and now they check a parameter given in the URI, and it works just fine.
      Any idea why this happens?

    • @jfversluis
      @jfversluis  3 роки тому

      @@jwj4535 hm not without any code or looking into it. Glad you figured it out!

  • @LobsterHarry
    @LobsterHarry 3 роки тому

    Nice and clear ! Well done

  • @LobsterHarry
    @LobsterHarry 3 роки тому +1

    @Gerald Versluis: Another idea for a video. I am a single developer and I am struggling with the right subscription for Azure-Services. I just need a Webservice and a small SQL-Database for Testing-Purposes but the Azure-Calculator says it costs me a fortune, especially the SQL-Server. I think that many single developers would care about that subject...

    • @jfversluis
      @jfversluis  3 роки тому +1

      I think they changed something not too long ago. When you create an SQL database, make sure that you looks closely at the top. For me it says: Looking for Basic, x and y? And if you click that you go to another screen where you can set it to Basic which will cost you about 5 Dollars a month.

  • @Ruvindra960518
    @Ruvindra960518 3 роки тому +1

    Hi, Please also create a video for how to download files (ex: pdf) and open them within Xamarin.Forms Apps. Thanks!

    • @jfversluis
      @jfversluis  3 роки тому

      I've made something like this now here: ua-cam.com/video/BcFlZMhPmVk/v-deo.html

  • @anassnassim
    @anassnassim 3 роки тому +2

    thank you for this great tutorial
    how I can when upload image retrieve the link to show in my app Xamarin

    • @jfversluis
      @jfversluis  3 роки тому +1

      Thank you Anass! Two methods come to mind: make the link predictable, so just have the root of the link in your app already, just add the filename of the file that you just uploaded and you have your link.
      Or, in the response of the upload action you can add some content or header that will return the link of the file that was just uploaded :)

  • @gizmo3399
    @gizmo3399 3 роки тому

    I remember doing something like this a few years back. Except i ran into an issue where uploading a larger video caused the app to crash because i loaded the entire video into memory and sent it to the server as one whole. I had to implement uploading with content-disposition on the server side to basically upload the video in chunks to avoid filling up the memory.
    Now i dont know if the default ways of uploading have changed but does the example you show handle large files well? otherwise a video about uploading large files in chunks might be useful to people. Maybe we could collaborate on it if you like.

    • @jfversluis
      @jfversluis  3 роки тому

      Oooh interesting, yeah that might be true! Send me a message and see if we can work together, that sounds fun!

  • @colinpeeris2538
    @colinpeeris2538 2 роки тому

    Great video! Thanks!
    Can this be done using a public ip address such that the mobile app can be used outside the server's network.

    • @jfversluis
      @jfversluis  2 роки тому

      Of course absolutely!

    • @colinpeeris2538
      @colinpeeris2538 2 роки тому

      @@jfversluis Thanks so much for your reply Gerald! Is there a reference you could point me to in order to implement using a public ip address? Right now, I can get everything you've shared to work when I'm on my own machine and when the android device is on the same network. However, it stops working when the app is running on an external network unfortunately.

    • @jfversluis
      @jfversluis  2 роки тому +1

      Honestly it shouldn’t be more than changing the address. However, then security measures come into play. You’ll want to check if your remote server needs any special headers or query parameters etc to specify a security key or maybe on the server-side see if you’ve set it up correctly to receive remote connections.
      It’s pretty hard to make a video about because there could be a million different reasons why it isn’t working

  • @codigoadictivo
    @codigoadictivo 3 роки тому +1

    Hi Gerald hehe , could you please point me in the right direction or make a video on how to download a XML file from onedrive to xamarin forms (iOS)?
    I know how to read embedded XML file, but in this case I need to download the file from internet(url)(as example one drive, google drive, dropbox etc...)
    Thanks

    • @jfversluis
      @jfversluis  3 роки тому

      Is it a publicly accessible URL?

    • @codigoadictivo
      @codigoadictivo 3 роки тому

      @@jfversluis well it will be a private folder with a XML file in one drive, but if it is too complicated with password, I can start learning how to do it in a public folder url.

    • @jfversluis
      @jfversluis  3 роки тому

      Yeah with all the authentication involved it can be a hard thing to implement. From a public url it’s much easier. I do it with JSON here: ua-cam.com/video/rq3iok03q7E/v-deo.html that should get you started

    • @codigoadictivo
      @codigoadictivo 3 роки тому +1

      @@jfversluis ooohh nice nice nice, I will see the video, yes i can make some sacrifices and use a public folder since the information that will be stored in the xml file is not that sensitive.
      Thank you. 🙂✌🏽

  • @Andres-wo5oi
    @Andres-wo5oi 2 роки тому

    thank you very much, muchas gracias tus videos han transcendido hasta habla hispana, por favor si puedes mantener los subtítulos en tus videos. para los que no entendemos ingles es una guiá.

    • @jfversluis
      @jfversluis  2 роки тому

      That is great Andres! Muchas gracias! All my videos will have subtitles, sorry it’s only in English, my Spanish isn’t great 😢
      You might also want to check Javier’s channel, I think he has some Spanish content: ua-cam.com/users/JavierSu%C3%A1rezRuiz

  • @AnimeTrailer2013
    @AnimeTrailer2013 3 роки тому

    can you make a video on how to select a file and send it as attachment with smtp? thanks

    • @jfversluis
      @jfversluis  3 роки тому

      Send it directly through smtp from the app?

    • @AnimeTrailer2013
      @AnimeTrailer2013 3 роки тому

      @@jfversluis yes, i have been trying for the past 3 hours, and just now i managed to pull it .. now its working xD , but still i prefer if we can have a full video details about smtp, using app, for example, the page i was working on have name, email, phone no, message box, and attachment.. when user press send, it will go to the email... the email will have all details along with attachment.. btw it worked while i used portion of your other video titled (Using FilePicker in Xamarin Essentials to Pick PDFs, Images and More!)

  • @LobsterHarry
    @LobsterHarry 3 роки тому +1

    Maybe for one of the next Videos: best practice to publish an App. Especially I am looking for ways without using a store. I publish my Apps only locally and right now I just deploy the APK to device manually. There must be better ways...

    • @jfversluis
      @jfversluis  3 роки тому

      Ooh that is a nice one! Have you looked into MDM solutions or maybe App Center?

    • @LobsterHarry
      @LobsterHarry 3 роки тому +1

      @@jfversluis, MDM solutions is new to be, but looks promising. I checked out App Center already but it did not figure out how to push an update to a Device. I develop apps for mobile Barcode-Scanner (Android) that should not have any access to Google Store, E-Mail, etc. They run in a Kiosk-Mode. I think that this scenario of an only intern use of an app is not very well documented in the web. Be the first ! ;-)

    • @jfversluis
      @jfversluis  3 роки тому

      @@LobsterHarry very true. While I do hear a lot of people having these scenarios so that’s cool.
      Ah you really want to automatically update? I do know app center has in-app updates and you can make them mandatory, but it will still be the user that has to do it

    • @LobsterHarry
      @LobsterHarry 3 роки тому +1

      @@jfversluis, you see that there are a lot of options... Please help us through this jungle ! I can image that those kind of subject does not challenge you very much but I see not other guys who are offering those things. Be unique ! ;-)

  • @sethisaacks8683
    @sethisaacks8683 Рік тому

    what about the reverse? Download a file from blob server to api then from the api to Xamarin?

  • @emax1500
    @emax1500 3 роки тому

    This is great. Thank you.

  • @WarnerBrosers
    @WarnerBrosers 3 роки тому

    Awesome! Keep going!))

  • @dreamhunter2895
    @dreamhunter2895 3 роки тому +1

    Great, thanks. Is it possible to select multiple images and upload through media picker. eagerly waiting for your response.

    • @jfversluis
      @jfversluis  3 роки тому

      Picking multiple images at once isn’t supported yet. The MediaPicker only provides the picking, you will have to upload yourself a video on that is here: ua-cam.com/video/KPDGtLeNClQ/v-deo.html

    • @dreamhunter2895
      @dreamhunter2895 3 роки тому +1

      Sir, thanks for a prompt response. I am using xamarin essential file picker to select multiple images and file uploader plugin to upload .can you help me on this how can I send multiple images through this.

    • @jfversluis
      @jfversluis  3 роки тому

      @@dreamhunter2895 I think I mention something about multiple files, right? Here are the docs: docs.microsoft.com/xamarin/essentials/file-picker?tabs=ios#pick-multiple-files
      And here is a video on how to upload files: ua-cam.com/video/KPDGtLeNClQ/v-deo.html

    • @dreamhunter2895
      @dreamhunter2895 3 роки тому

      @@jfversluis Sir, Thanks for your valuable response. Refer My code actually i want to upload multiple images through FileUploder plugin.
      private async void ImageButton_Clicked(object sender, EventArgs e)
      {
      var pickResult = await FilePicker.PickMultipleAsync(new PickOptions
      {
      FileTypes = FilePickerFileType.Images,
      PickerTitle = "Pick image(s)"
      });
      if (pickResult != null)
      {
      foreach (var image in pickResult)
      {
      var stream = await image.OpenReadAsync();
      imageList.Add(ImageSource.FromStream(() => stream));
      paths.Enqueue(ImageSource.FromStream(() => stream).ToString());
      }
      collectionView.ItemsSource = imageList;
      }
      }
      private async void Upload_Clicked(object sender, EventArgs e)
      {
      try
      {
      if (isBusy)
      return;
      isBusy = true;
      progress.IsVisible = true;
      //Uploading multiple images at once
      List pathItems = new List();
      while (paths.Count > 0)
      {
      filename = $"{Docketnumber1 + DateTime.Now.ToBinary()}.jpeg";
      pathItems.Add(new FileBytesItem("", , filename)); (Here i am not able to add Address of the images which i am getting from filepicker)
      }
      await CrossFileUploader.Current.UploadFileAsync($"{GlobalVariables.BaseUri}/PostDocument", new FileBytesItem("", fileAsByteArray, filename), new Dictionary()
      {
      {"docket" ,Docketnumber1 }
      /**/
      });

    • @dreamhunter2895
      @dreamhunter2895 3 роки тому

      Please help me or direct me to correct my code to upload multiple images.

  • @IndraHermanto-bn9rb
    @IndraHermanto-bn9rb Рік тому

    hi... thanks for this learning video... can i ask you something regarding this video ? There's no error but the image was no save on upload folder (iis web server ). Is there any clue / any step that i must do, so image can be save in the server

    • @jfversluis
      @jfversluis  Рік тому

      There has to be some error or message somewhere. Carefully check the logs on both client and server

  • @tomoorizardo745
    @tomoorizardo745 3 роки тому

    hey man nice tutorial.
    how do you do this with more payload. For example a blog post who has id ,author name, etc etc.

    • @jfversluis
      @jfversluis  3 роки тому

      I think your request can consist of multiple types of data. Or else, just make it a second request that might even be simultaneous.

  • @robertocruz231
    @robertocruz231 3 роки тому

    Great tutorial, how can I do for to send additional data to the api?

    • @jfversluis
      @jfversluis  3 роки тому +1

      Typically that is done through a separate request! Think about it… which app lets you set both the profile image and other profile details in one go? They are usually separate:)

  • @kevinrashmika2755
    @kevinrashmika2755 2 роки тому

    How to select and upload multiple images to server.. 🤔🤔 anywhere do not have resources about that..

    • @jfversluis
      @jfversluis  2 роки тому

      Find a picker that allows you to pick multiple files and call this in a for loop :D

  • @teymurasadov295
    @teymurasadov295 3 роки тому

    Great video!
    But how can I achieve posting image with some other model ?

    • @jfversluis
      @jfversluis  3 роки тому

      What do you mean with some other model?

    • @teymurasadov295
      @teymurasadov295 3 роки тому

      @@jfversluis for example I want to post a class which has an image as a property

    • @jfversluis
      @jfversluis  3 роки тому

      What you see happening a lot is that the data and the image is sent separately, you might want to consider doing that

    • @teymurasadov295
      @teymurasadov295 3 роки тому

      @@jfversluis yes I know that approach. However I wanted to achieve it in one go

    • @jfversluis
      @jfversluis  3 роки тому

      @@teymurasadov295 I’m not even sure that’s possible tbh

  • @stryder12345
    @stryder12345 2 роки тому

    Will this method works for multiuploading? E.g i want upload 3 photos, so i must write content.add three times?

    • @jfversluis
      @jfversluis  2 роки тому

      No, you’ll have to upload three file separately

    • @stryder12345
      @stryder12345 2 роки тому

      @@jfversluis ah, ok, got it, thanks)

  • @dreamhunter2895
    @dreamhunter2895 2 роки тому

    Sir , It was working with http but when i change to Https then stop working . Please suggest on this. is it not supported HTTPS ?

    • @jfversluis
      @jfversluis  2 роки тому

      HTTPS is definitely supported, should just work :)

  • @dreamhunter2895
    @dreamhunter2895 3 роки тому +1

    Sir, Please help me to pass array of image address into CrossFileUploader.Current.UploadFileAsync with file name

    • @jfversluis
      @jfversluis  3 роки тому +1

      Not sure what you mean by an array of image address. You mean uploading multiple files?

  • @dreamhunter2895
    @dreamhunter2895 2 роки тому

    Sir, When i have changed to Https then getting error(Java.IO.IOException: stream was reset: PROTOCOL_ERROR
    at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod) etc. Please suggest Sir on this.

    • @jfversluis
      @jfversluis  2 роки тому

      No idea, sorry. Should just work :) maybe check it it works from a console application? Or even just from the browser?

  • @dreamhunter2895
    @dreamhunter2895 3 роки тому

    Sir, Please make video tutorials on multiple file upload in Xamarin. I am getting the same video every where.

    • @jfversluis
      @jfversluis  3 роки тому

      Multiple files is just putting a for loop around this 😄

    • @dreamhunter2895
      @dreamhunter2895 3 роки тому

      @@jfversluis Sir, will it work in HTTP 2 ??

    • @jfversluis
      @jfversluis  3 роки тому

      I would think so

  • @sipepguru
    @sipepguru 3 роки тому

    Hey buddy 😀

    • @jfversluis
      @jfversluis  3 роки тому +1

      Hello friend! Thanks for watching again :D

  • @AMIRKHAN-dm2fm
    @AMIRKHAN-dm2fm 3 роки тому +1

    hi sir can we store files on Azure blob storage?

    • @jfversluis
      @jfversluis  3 роки тому

      You absolutely can! I’m guessing you want a video about it ;)

    • @AMIRKHAN-dm2fm
      @AMIRKHAN-dm2fm 3 роки тому

      @@jfversluis yes sir if u make a tutorial its really really helpful.😊

    • @jfversluis
      @jfversluis  3 роки тому

      I've recorded it! Planning to release it next week. If you want to see it right now consider a membership! ua-cam.com/channels/BBZ2kXWmd8eXlHg2wEaClw.htmljoin

  • @maxipunchik
    @maxipunchik 3 роки тому

    is this method just calling the standard intent?

    • @jfversluis
      @jfversluis  3 роки тому

      Sorry, I’m not sure what you mean by this

    • @maxipunchik
      @maxipunchik 3 роки тому

      @@jfversluis If I press a button on my phone, I'm prompted to choose an app that I can use to take a photo

    • @jfversluis
      @jfversluis  3 роки тому

      @@maxipunchik ah right. I would expect it to leverage that same mechanism yes. If you have more than one camera app and not specified a default one, you will be asked. If you have a default one, that will be used.

  • @linglu7108
    @linglu7108 2 роки тому

    How to barcode scanner in Xamarin Form through web API , I have made web API project which is connect to sql server Database. I try to Scan Barcode result(Data) through Web API to sql server Database.

    • @linglu7108
      @linglu7108 2 роки тому

      you are great teacher , I learn a lot of things from you. Give suggestion or share some code , that's great!

    • @jfversluis
      @jfversluis  2 роки тому

      I’m sorry, I don’t think I understand what you’re asking… thank you for the kind words!

    • @linglu7108
      @linglu7108 2 роки тому

      @@jfversluis I want to Barcode scanner Result(example :Barcode 123456780) go to Sql server DataBase , but Xamarin form can not go to sql server Database , I want use webAPi with Bridge to connect Barcode Scanner Result with webAPI , webAPI can go through SQL serverDataBase,Thanks for your Help

  • @Wajih_Ahmed
    @Wajih_Ahmed 2 роки тому

    Helpful video but how can we upload multiple files

    • @jfversluis
      @jfversluis  2 роки тому

      Add a for loop 😆

    • @Wajih_Ahmed
      @Wajih_Ahmed 2 роки тому

      @@jfversluis on api side multiple uploads are working but on xamarin side multiple picker is not working

    • @jfversluis
      @jfversluis  2 роки тому

      @@Wajih_Ahmed ah that might be. I think that wasn’t available on all platforms when this was first implemented. Also there then a loop where you select multiple files or you’ll have to implement something custom for file picking

  • @ulviugur3605
    @ulviugur3605 3 роки тому

    Well intended example which did not work for me. Also jumping some bits did not help, hard coded IPs could be OK if the UploadFile context was working properly. Potential issues with the sample source code :/

    • @jfversluis
      @jfversluis  3 роки тому

      What doesn’t seem to work for you?

  • @arslanmehboob8188
    @arslanmehboob8188 3 роки тому

    hi, how to send any upload file like doc,pdf,image,video on one click button with attachment to asp.web api

    • @jfversluis
      @jfversluis  3 роки тому

      Not sure what you mean. The file type shouldn’t matter :)

    • @arslanmehboob8188
      @arslanmehboob8188 3 роки тому

      @@jfversluis can we send any file type to asp.web api?? but PickPhotoAsync method open only media gallery for images not select pdf file or doc file

    • @jfversluis
      @jfversluis  3 роки тому

      That’s true. Use the file picker, the rest should mostly be the same :)

    • @arslanmehboob8188
      @arslanmehboob8188 3 роки тому

      @@jfversluis please send file picker code upload file to asp.web api

    • @jfversluis
      @jfversluis  3 роки тому

      Here is a video for the file picker :)
      ua-cam.com/video/4gV9ZV61rn4/v-deo.html

  • @minafawzy5605
    @minafawzy5605 Рік тому

    can I pass json object with an array of files?

    • @jfversluis
      @jfversluis  Рік тому +1

      You can, but you can't use that to upload multiple files at once :D

    • @minafawzy5605
      @minafawzy5605 Рік тому

      @@jfversluis thanks for reply if you could show me how to add json object wil be great