writting to file
This commit is contained in:
parent
6fec9c1ca9
commit
a5bd6eeedb
@ -1,4 +1,7 @@
|
|||||||
use suppaftp::{NativeTlsFtpStream, NativeTlsConnector};
|
use std::fs::File;
|
||||||
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
|
use suppaftp::{FtpError, NativeTlsConnector, NativeTlsFtpStream};
|
||||||
use suppaftp::native_tls::{Certificate, TlsConnector, TlsStream};
|
use suppaftp::native_tls::{Certificate, TlsConnector, TlsStream};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -10,6 +13,13 @@ fn main() {
|
|||||||
let mut ftp_stream = ftp_stream.into_secure(NativeTlsConnector::from(TlsConnector::builder().add_root_certificate(cert).build().unwrap()), "gitea.piwalker.net").unwrap();
|
let mut ftp_stream = ftp_stream.into_secure(NativeTlsConnector::from(TlsConnector::builder().add_root_certificate(cert).build().unwrap()), "gitea.piwalker.net").unwrap();
|
||||||
assert!(ftp_stream.login("anonymous", "anonymous@").is_ok());
|
assert!(ftp_stream.login("anonymous", "anonymous@").is_ok());
|
||||||
|
|
||||||
|
let mut file = File::create("test.txt").unwrap();
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
ftp_stream.retr("modpacks.json", |stream| {
|
||||||
|
stream.read_to_end(&mut buf).map_err(|e| FtpError::ConnectionError(e))
|
||||||
|
}).unwrap();
|
||||||
|
file.write_all(buf.as_slice()).unwrap();
|
||||||
|
|
||||||
assert!(ftp_stream.quit().is_ok());
|
assert!(ftp_stream.quit().is_ok());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user