dani-garcia / rust_async_ftp

Fork of https://crates.io/crates/ftp with tokio async support
Apache License 2.0
21 stars 14 forks source link

Async PUT from stream #12

Open mihaigalos opened 2 years ago

mihaigalos commented 2 years ago

I'm trying to use a loop to read data from a file, PUT it to a FTP server and update a progress bar. tokio::fs::File already implements the R trait trait in put:

pub async fn put<R: AsyncRead + Unpin>(&mut self, filename: &str, r: &mut R) -> Result<()>

So one can just write something like:

let mut file = tokio::fs::File::open(&filename).await.unwrap();
let mut ftp_stream = FtpStream::connect(server_address);
ftp_stream.put(filename, &mut file).await.unwrap();

Qs:

mihaigalos commented 2 years ago

Not sure if possible, but of potential interest: usage of async_stream::stream! for https PUT.

mihaigalos commented 2 years ago