Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FTP client for Rust

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

mattnenterprise/rust-ftp

Repository files navigation

FTP client for Rust

Number of Crate DownloadsCrate VersionCrate LicenseBuild StatusCoverage Status

Documentation


Installation

FTPS support is achieved throughrust-native-tls and is disabled by default. To enable itsecure should be activated inCargo.toml.

[dependencies]ftp = {version ="<version>",features = ["secure"] }

Usage

externcrate ftp;use std::str;use std::io::Cursor;use ftp::FtpStream;fnmain(){// Create a connection to an FTP server and authenticate to it.letmut ftp_stream =FtpStream::connect("127.0.0.1:21").unwrap();let _ = ftp_stream.login("username","password").unwrap();// Get the current directory that the client will be reading from and writing to.println!("Current directory: {}", ftp_stream.pwd().unwrap());// Change into a new directory, relative to the one we are currently in.let _ = ftp_stream.cwd("test_data").unwrap();// Retrieve (GET) a file from the FTP server in the current working directory.let remote_file = ftp_stream.simple_retr("ftpext-charter.txt").unwrap();println!("Read file with contents\n{}\n",str::from_utf8(&remote_file.into_inner()).unwrap());// Store (PUT) a file from the client to the current working directory of the server.letmut reader =Cursor::new("Hello from the Rust\"ftp\" crate!".as_bytes());let _ = ftp_stream.put("greeting.txt",&mut reader);println!("Successfully wrote greeting.txt");// Terminate the connection to the server.let _ = ftp_stream.quit();}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionallysubmitted for inclusion in the work by you, as defined in the Apache-2.0license, shall be dual licensed as above, without any additional terms orconditions.

Development environment

All you need to develop rust-ftp and run the tests is Rust and Docker.Thetests folder contains aDockerfile that installs and configuresthe vsftpd server.

To create the Docker image:

docker build -t ftp-server tests

To start the FTP server that is tested against:

tests/ftp-server.sh

This script runs theftp-server image in detached mode and starts thevsftpd daemon. It binds ports 21 (FTP) as well as the range 65000-65010 for passive connections.

Once you have an instance running, to run tests type:

cargotest --features secure

The following commands can be useful:

# List running containers of ftp-server image# (to include stopped containers use -a option)docker ps --filter ancestor=ftp-server# To stop and remove a containerdocker stop container_namedocker rm container_name# To remove the imagedocker rmi ftp-server

About

FTP client for Rust

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors15


[8]ページ先頭

©2009-2025 Movatter.jp