wiomoc / whatsappweb-rs

WhatsApp Web client for Rust
MIT License
122 stars 37 forks source link

Sending media #13

Open mpwsh opened 5 years ago

mpwsh commented 5 years ago

Hi wiomoc, i'm having a hard time figuring out how to send media files with the new version of the library. The media.rs example is not working anymore, because of some deprecated calls. Can you give me a hint on how to do it now?

let mut file = Vec::new();
            let contents = File::open("path/to/image.jpg").unwrap();
            let contents_2 = contents.try_clone().unwrap();
            contents_2.read_to_string(&mut file).unwrap();

            let connection0 = connection.clone();
            let (thumbnail, size) = crypto::encrypt_media_message(MediaType::Video, &file);
            let thumbnail = Arc::new(thumbnail);

            connection0.request_file_upload(&file, MediaType::Video, Box::new(move |file_info| {                
               connection0.send_message(ChatMessageContent::Image(file_info.unwrap(), size, thumbnail.to_vec()), accepted_jid);
        }));

tried this way but its not working