When I was developing my senior year project at university, I faced a problem in uploading file (image file in my case) from Android to Nodejs server. After grinding for continous hours, I was able to find full working solution.
🔥 Steps:
- Clone this Repository. You will get both android and nodejs code.
- Open Nodejs folder and install required dependencies
npm install
- Run nodejs code
node index
or just
node
- Open Android code
- Change IP address (if required) in MainActivity.java variable named "UPLOAD_URL". Which look something like this
String UPLOAD_URL = "http://localhost:3000/api/image";
- Run app on your Android device.
- That's it.
Note: My Android Studio Version is 3.0, Gradle Build v3.3, Tested on Nexus 6p on Android P. It's working perfectly on my device 💯.
Licensed Under GPL 3.0.