This content originally appeared on DEV Community and was authored by chinmay chhajed
Isn't it tedious to always reach out for a USB cable and then connect phone with computer, wait while computer detects, then browse for files and then finally transfer! What a pain to do so many steps.
Worry not, here is a wireless solution to copy data from one device to other. All you need is Python and a supporting mobile app!
To do this, we will be using a simple concept: HTTP Server and Client. A server will be source of files and a client will be the one copying files from server.
Since we will be transferring files wireless, we need to connect mobile and computer to a common WiFi router. If you don't have a router, turn hotspot on from your mobile and connect your computer to it.
Transfer files from computer to phone
- Make sure you have python installed. If not then first install python.
- Next step is to check version of python. Open a terminal (or command prompt on Windows) and run
python --version
- If you have a python version starting from
3.x
, then run the commandpython -m http.server
in terminal. - If your python version is
2.x
then runpython -m SimpleHTTPServer
-
Next get the private IP address of your machine.
- For Windows, open command prompt and run
ipconfig
. Your local IP address will be listed under ‘IPv4 Address’. - For Linux and Mac, open terminal and run command
ifconfig
. In the resulting information spewed out, we are looking for the section starting withwl
. It could bewlp3s0
or something else. Basically it denotes wireless lan. Under this section, we need address afterinet
. In my case, it's192.168.10.11
.
- For Windows, open command prompt and run
Once we have the IP address, go to the browser in your phone and enter that address with a
:8000
at the end in address bar. This8000
comes from the output ofpython -m http.server
command. As you can see in above image, default port is8000
. For my case, I would enter192.168.10.11:8000
in my mobile browser and go to the link. Once the page loads, congrats, you may navigate to the file and download it.If page doesn't load in mobile browser, make sure that you do not have a
https://
at start of URL. If present then remove it.
Bonus: If you need a specific file, then in terminal navigate to the directory where file is present and run the python server command in that directory. Python server will start from which ever directory command is executed.
Transfer files from phone to computer
- For this you will need a mobile app to run HTTP Server like this or any other app. Just open the app and run the server. For this app, click on "off" to turn the server on.
- Open the link given on computer browser. From above screenshot,
192.168.10.2:12345/
. And done! Browser files present in your phone from your computer.
- Open the link given on computer browser. From above screenshot,
This content originally appeared on DEV Community and was authored by chinmay chhajed
chinmay chhajed | Sciencx (2021-02-22T08:53:35+00:00) Transfer files between your phone and computer without any cable and internet!. Retrieved from https://www.scien.cx/2021/02/22/transfer-files-between-your-phone-and-computer-without-any-cable-and-internet/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.