Solution Timeline

All versions (edits) of solutions to Small simple Python FTP upload script appear below in the order they were created. Comments that appear under revisions were those created when that particular revision was current.

To see the revision history of a single solution (with diffs), click on the solution number (ie. "#1") in the upper right corner of a solution revision below.

← Bounty Expand all edits

gist

https://gist.github.com/thelostt/849e4352709679e0b33d3769031cdb5b

usage

fetch_upload.py --local-path /target/local/path --remote-path /ftp/target/path --ftp-server SERVER --user USER --password PASSWORD

current behavior

First it tries to unzip all zipped files, and place them to /path/to/zippedfile_fetch. Then, it will upload all files (except for the zipped ones as wanted) to a specific directory in the ftp server, following the same path structure as in the local target.

Let me know if you get any issues. Cheers.

Winning solution

Recursive FTP Upload Solution

Tested in Ubuntu

Instructions

sudo apt-get install python-pip -y

sudo pip install configargparse zipfile

save the code in ftp_sol.py or some_file_name.py

python ftp_sol.py -u subhash_username -p password -s 192.168.5.5 -po 5555 -r /var/www/html/test

python ftp_sol.py --help

usage: ftp_sol.py [-h] -u [-p] -s [-po] -r

optional arguments:

-h, --help show this help message and exit

-u , --username FTP Username

-p , --password FTP Password

-s , --host FTP Host

-po , --port FTP Port Default 21

-r , --path local path

It will recursively create directories in FTP Server and upload the files
It also scan the zip files in local path unzip under same zip name then upload files by creating folders

Recursive FTP Upload Solution

Tested in Ubuntu

Instructions

Python 2.7

sudo apt-get install python-pip -y

sudo pip install configargparse zipfile

save the code in ftp_sol.py or some_file_name.py

python ftp_sol.py -u subhash_username -p password -s 192.168.5.5 -po 5555 -r /var/www/html/test

python ftp_sol.py --help

usage: ftp_sol.py [-h] -u [-p] -s [-po] -r

optional arguments:

-h, --help show this help message and exit

-u , --username FTP Username

-p , --password FTP Password

-s , --host FTP Host

-po , --port FTP Port Default 21

-r , --path local path

It will recursively create directories in FTP Server and upload the files
It also scan the zip files in local path unzip under same zip name then upload files by creating folders