GithubHelp home page GithubHelp logo

standardgalactic / ftpclient.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from invenia/ftpclient.jl

0.0 1.0 0.0 5.88 MB

Julia FTP client using LibCURL.jl

License: Mozilla Public License 2.0

Julia 100.00%

ftpclient.jl's Introduction

FTPClient.jl

CI codecov

A Julia FTP client using LibCURL supporting FTP and FTP over SSL.

Examples

Depending on the settings of the FTP server you are connecting to you may need to deal with various security settings.

  • FTP with no Transport Layer Security (FTP). Typically uses port 21/TCP.

    julia> ftp = FTP(hostname="example.com", username="user", password="1234")
    URL:       ftp://user:*****@example.com/
    Transfer:  passive mode
    Security:  none
    
    julia> ftp = FTP("ftp://user:[email protected]")
    URL:       ftp://user:*****@example.com/
    Transfer:  passive mode
    Security:  none
  • FTP with implicit security (FTPS). Typically uses port 990/TCP.

    julia> ftp = FTP(hostname="example.com", username="user", password="1234", ssl=true, implicit=true)
    URL:       ftps://user:*****@example.com/
    Transfer:  passive mode
    Security:  implicit
    
    julia> ftp = FTP("ftps://user:[email protected]")
    URL:       ftps://user:*****@example.com/
    Transfer:  passive mode
    Security:  implicit
  • FTP with explicit security (FTPES). Typically uses port 21/TCP.

    julia> ftp = FTP(hostname="example.com", username="user", password="1234", ssl=true, implicit=false)
    URL:       ftpes://user:*****@example.com/
    Transfer:  passive mode
    Security:  explicit
    
    julia> ftp = FTP("ftpes://user:[email protected]")
    URL:       ftpes://user:*****@example.com/
    Transfer:  passive mode
    Security:  explicit

Once you've created your FTP instance you can use many of the filesystem functions that Julia provides. A quick example showing some of the functions available:

julia> cd(ftp, "Documents/School")

julia> pwd(ftp)
"/Documents/School"

julia> readdir(ftp)
1-element Array{String,1}:
 "Assignment1.txt"
 "Assignment2.txt"

julia> io = download(ftp, "Assignment1.txt");  # Download as IO stream

julia> download(ftp, "Assignment2.txt", "./A2/Assignment2.txt");  # Save file to a specified path

julia> upload(ftp, "Assignment3.txt", ".")  # Upload local file "Assignment3.txt" to FTP server home directory

julia> open("Assignment3.txt") do fp
           upload(ftp, fp, "Assignment3-copy.txt")  # Upload IO content as file "Assignment3-copy.txt" on FTP server
       end

julia> mv(ftp, "Assignment3-copy.txt", "Assignment3-dup.txt")

julia> rm(ftp, "Assignment3-dup.txt")

julia> mkdir(ftp, "tmp")

julia> rmdir(ftp, "tmp")

julia> close(ftp)

If you want to upload a file but retry on failures you can do the following:

julia> ftp_retry = retry(delays=fill(5.0, 3)) do
           upload(ftp, "Assignment3.txt", ".")
       end

julia> ftp_retry()

FAQ

Downloaded files are unusable

Try downloading file in both binary and ASCII mode to see if one of the files is usable.

Linux and Travis CI

Travis CI currently [does not reliably support FTP connections on sudo-enabled Linux]https://blog.travis-ci.com/2018-07-23-the-tale-of-ftp-at-travis-ci). This will usually manifest itself as a Connection Timeout error. Disable sudo for a workaround.

ftpclient.jl's People

Contributors

ararslan avatar fchorney avatar femtocleaner[bot] avatar iamed2 avatar juliatagbot avatar kano31 avatar mjram0s avatar morris25 avatar nicoleepp avatar omus avatar rofinn avatar staticfloat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.