Issue
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?
Solution
NanoHTTPD
is good for handling file uploads and downloads. If you want to download files use the serveFile
method by extending and overriding the serve
method. In order to handle uploads, check for a POST
request and get the file from files
parameter. You'll get a temporary path where the uploaded file is placed. Use a FileInputStream
to read the file and do whatever you want. Hope that answers your question.
Answered By - Ragunath Jawahar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.