I want my Android device to act as a HTTP server. When I start my server on my device it should show an IP address. When I access this device’s IP address through my desktop PC (same network), I should be able to upload files from my desktop to the Android device.
I’ve tried NanoHttpd.java but it’s hard to use and I want to use the same for downloading files as well. Is there any better solution to achieve these?
NanoHTTPDis good for handling file uploads and downloads. If you want to download files use theserveFilemethod by extending and overriding theservemethod. In order to handle uploads, check for aPOSTrequest and get the file fromfilesparameter. You’ll get a temporary path where the uploaded file is placed. Use aFileInputStreamto read the file and do whatever you want. Hope that answers your question.