Book Image

Xamarin Mobile Application Development for Android, Second Edition

Book Image

Xamarin Mobile Application Development for Android, Second Edition

Overview of this book

Table of Contents (18 chapters)
Xamarin Mobile Application Development for Android Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Upload an image using an HTTP multipart


The last functionality we are left to incorporate in the POIApp sample application is to upload the captured POI image to the server. Currently, we are saving only the POI details on Cloud, and the POI images are stored locally on the user's device memory. It would be nice to upload the image to the server so that we don't lose the images when a user deletes them locally from a device.

If the user has captured the photo of the POI and it is available locally on the device memory, then the save action will post the image along with the data using multipart form upload. Otherwise, it will post just the POI JSON data for the save operation.

Before we create a multipart form data request, let's first understand the web service API specification. The following block describes the web service API requirements for a multipart form upload:

Endpoint: com.packt.poiapp/api/poi/upload
Request-Type: multipart/form-data POST
    -----BOUNDARY
    Content-Disposition...