Open mihaigalos opened 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:
PUT
tokio::fs::File
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:
loop
r
Not sure if possible, but of potential interest: usage of async_stream::stream! for https PUT.
https
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 input
:So one can just write something like:
Qs:
loop
to buffer-read from the file and async PUT it to the ftp stream?r
in theput
signature need to be mutable? I'm kind of confused, since we just read from the file. I see here,r
is just copied.