Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken Files when upload rar,zip,msi,etc #112

Open
her0mx opened this issue Jan 6, 2023 · 1 comment
Open

Broken Files when upload rar,zip,msi,etc #112

her0mx opened this issue Jan 6, 2023 · 1 comment

Comments

@her0mx
Copy link

her0mx commented Jan 6, 2023

I make a test to upload files with format: Zip, Rar,MSI, Exe, etc and always the file when it's uploaded its modified and then broken when it's downloaded and try to open.

on the other hand if i upload files type text like .txt, .php,.html,.js , etc i don't experiment any problem.

here it's the code example

use std::fs::{read, write};
use std::str;
use std::io::Cursor;
use ftp::FtpStream;


fn main() {
    let mut ftp_stream = FtpStream::connect("somehost.com:21").unwrap();
    let _ = ftp_stream.login("some_user", "some_password").unwrap();
    let read_bytes = read("test_file.rar").unwrap();
    let bytes = read_bytes.as_slice();
    println!("Total bytes read  : {}",read_bytes.iter().count());
    let mut reader = Cursor::new(bytes);
    let bytes_reader = reader.clone().into_inner();

    println!("Totalt bytes after reader {}",bytes_reader.iter().count());
                ftp_stream.cwd("public_html").unwrap();
                let _ = ftp_stream.put("file.rar", &mut reader);
}

'till this moment i know the problem exist when make the stream of the bytes, 'cause if i write the bytes of the reader on my disk the file it's OK.

So i will check the code of the stream to see what's it's going on.

Tested ON: Windows 10 21H2 and Mac OS Monterrey 12.6

@veeso
Copy link
Contributor

veeso commented Feb 1, 2023

Please, try with https://github.com/veeso/suppaftp instead, which is the maintained version of this library and set the transfer type to Binary with the transfer_type function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants