Can't find data cable to transfer a file? I got you covered :)
Derived from the concept of ShareIt/Xender (file transfer applications), share-it is the pythonic way to do the same only with much ease!
-
Make sure you have python2 installed on your system
-
You can switch to a virtual env (optional, but a good practice) (a) Install virtualenv. (b) Use the following commands: i.
virtualenv -p $(whereis python2) <env_name>
ii.source <env_name>/bin/activate
iii. For exiting virtual env. use -deactivate
-
pip install -r requirements.txt
-
Set
UPLOAD_FOLDER
&PASSWORD
enironment variable. Note that this is optional. (a) Default value forUPLOAD_FOLDER
is script's directory. (b) Default value forPASSWORD
ismuggle
. -
To transfer from any device to PC, connect devices on the same network and start the app using:
UPLOAD_FOLDER=/path/to/upload/directory python /path/to/share-it/app.py
-
Default port is 8000 (
PORT
can be set in the environment if you want to use different port). -
Head to IP_ADDRESS:PORT on the other device, for e.g. 192.168.68.43:8000 (To find local IP:
ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
) -
To transfer from PC to any device, type the following command in the directory containing the file to be shared:
python3 -m http.server 8000
and visit IP_ADDRESS:PORT on the device (port can be any valid free port)
-
Add the following to your rc file (e.g. .bashrc, .zshrc)
if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi
-
Then create a .bash_aliases file in home directory with the following content:
alias send="python3 -m http.server 8000"
alias recv="python <path/to/share-it>/app.py"
-
Restart your terminal, or source the .rc file
-
For sending from PC, type
send
-
For recieving on PC, type
recv