Skip to content

Please help me to understand file upload #2712

Discussion options

You must be logged in to vote

I got the solution

 while let Some(item) = payload.next().await {
        let mut field = item.unwrap();

        let content_type = field.content_disposition();

        println!("{}", field.name());
        println!("CONTENT TYPE: {}", content_type);
        println!("FILE NAME: {}", content_type.get_filename().unwrap());
        println!("UPLOAD NAME FIELD: {}", content_type.get_name().unwrap());
        println!("MIME TYPE: {}", field.content_type());
        println!("FIELD: {:?}", field);

        let file_path = format!("pub/{:?}.jpg", time::Instant::now());
        let mut create_file = File::create(file_path).unwrap();

        while let Some(chunk) = field.next().await {

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@measproem
Comment options

@asonix
Comment options

asonix Oct 3, 2022
Collaborator

@measproem
Comment options

Answer selected by krishnaTORQUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants