0

I have an Android app, and a .NET Core 2.0 Web API. I would like to upload a picture, together with some data pertaining to the picture (UserID, PIN, etc). Quick googling points me to Microsoft docs which says you should use the IFormFile interface.

I would like to know if there is any way of uploading a file, as well as a json object to describe the picture being uploaded to the API? If not, would I have to create two action methods, one for the picture and the other for the json data? What would the best approach be?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Okuhle
  • 842
  • 3
  • 14
  • 31
  • Possible duplicate of https://stackoverflow.com/questions/41367602/upload-files-and-json-in-asp-net-core-web-api?rq=1 – Nkosi Jun 24 '18 at 22:15
  • The same doc tells you "IFormFile can be used directly as an action method parameter or as a viewmodel property, as shown above.". So, create a ViewModel with the data you want to pass as JSON – Camilo Terevinto Jun 24 '18 at 22:15
  • In Android, you could try making a multipart upload object – OneCricketeer Jun 24 '18 at 22:17

0 Answers0