A python code to build an FTP service

Source: Internet
Author: User
Tags create directory

Environment Construction:

    • Python
    • Windows/linux
    • Pip Install pyftpdlib (install failed please download here: https://pypi.python.org/pypi/pyftpdlib/)

A line of code to fix things:

To the directory you intend to share, python-m pyftpdlib

  

Then we look at this, a simple FTP server has been completed, access to ftp://127.0.0.1:2121 (the default IP is 127.0.0.1, port is 2121)

  

In addition to the above, there are some optional parameters:

    • I specify an IP address (default is native IP address)

    • P Specify port (default is 2121)

    • W Write permission (default is read-only)

    • D Specify directory (default to current directory)

    • U Specify user name Login

    • P Set Login Password

If you want to build an FTP service on your LAN:

 fromPyftpdlib.authorizersImportDummyauthorizer fromPyftpdlib.handlersImportFtphandler fromPyftpdlib.serversImportFtpserver#instantiate Dummyauthorizer to create an FTP userAuthorizer =Dummyauthorizer ()#Parameters: User name, password, directory, permissionsAuthorizer.add_user ('User','12345','e:\\', perm='ELRADFMWMT')#Anonymous Login#authorizer.add_anonymous ('/home/nobody ')Handler =Ftphandlerhandler.authorizer=Authorizer#parameters: IP, port, HandlerServer = Ftpserver (('0.0.0.0', +), handler)#set the IP address to 0.0.0.0 as the nativeServer.serve_forever ()

Read permissions:

    • "E" = Change directory (cwd,cdup command)

    • "L" = List file (list,nlst,stat,mlsd,mlst,size command)

    • "R" = Retrieving files from the server (RETR command)

Write permissions:

    • "A" = Append data to an existing file (AppE command)

    • "D" = delete file or directory (DELE,RMD command)

    • "F" = Rename file or directory (Rnfr,rnto command)

    • "M" = Create directory (MKD command)

    • "W" = Store file to server (Stor,stou command)

    • "M" = Change file Mode/permissions (SITE chmod command)

    • "T" = Change the file modification time (SITE mfmt command)

 

A python code to build an FTP service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.