GithubHelp home page GithubHelp logo

Damaged uploaded image about suppaftp HOT 3 CLOSED

veeso avatar veeso commented on May 25, 2024
Damaged uploaded image

from suppaftp.

Comments (3)

veeso avatar veeso commented on May 25, 2024

Hi,

I would try with stream.transfer_type(FileType::Binary)

from suppaftp.

nageslan avatar nageslan commented on May 25, 2024

Hi,

I would try with stream.transfer_type(FileType::Binary)

There seems to be a new problem after I modified it.:

Error Invalid response: [425] 425 You cannot use PASV on IPv6 connections. Use EPSV instead.

from suppaftp.

nageslan avatar nageslan commented on May 25, 2024

I've solved the problem and I think the README can work on it

use std::{fs};
use std::error::Error;
use std::fs::File;
use std::io::{Cursor, Read, Write};
use suppaftp::FtpStream;
use suppaftp::Mode::ExtendedPassive;
use suppaftp::types::FileType;


fn t()-> Result<(),Box<dyn Error>>{
    // Create a connection to an FTP server and authenticate to it.
    let mut ftp_stream = FtpStream::connect("1127.0.0.1:21")?;
    let _ = ftp_stream.login("account", "password")?;
    // Binary file transfer is supported
    ftp_stream.transfer_type(FileType::Binary)?;
    // Support for IPV6
    ftp_stream.set_mode(ExtendedPassive);
    // Switch ftp service directory
    let _ = ftp_stream.cwd("test_data")?;

    // put file.
    let mut file = fs::read("D:\\img.png")?;
    let x = file.as_slice();
    let mut cursor = Cursor::new(x);
    ftp_stream.put_file("greeting.png",& mut cursor)?;
    
    println!("Successfully wrote greeting.png");
    // Terminate the connection to the server.
    let _ = ftp_stream.quit();
    Ok(())
}

fn main() {
    match t() {
        Ok(_) => {}
        Err(e) => {
            println!("Error {}",e)
        }
    }
}

from suppaftp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.