Stdweb :: File object // get contents

  1. Context: I’m implementing file drag/drop for a Rust/wasm32 webapp.

  2. I’m using stdweb. I am using the DragDropEvent. From this, I get a FileList. From this, I print out the names of the files:

                            let n = file_list.len();
                            let msg = format!("handling dro pevent, num files: {:?}", n);
                            console!(log, msg);
                            for file in file_list.iter() {
                                let msg = format!("name: {:?}", file.name());
                                console!(log, msg);
                            }

Now, file is an object of type https://docs.rs/stdweb/0.4.17/stdweb/web/struct.File.html

  1. here is my problem: I can use file.name() to get the name of the file – but how do I extract the data from the File object ?

To read file’s content you need to use FileReader object. stdweb also has FileReader type, but it seems most of its methods are not yet implemented. Maybe you need to read file’s content from JS side and pass it again to Rust?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.