Help! trying to read a dropped file (on browser app) to a String with wasm_bindgen

Ok so far I have managed to get a
web_sys::ReadableStreamByobReader

from a dropped File item.
In this case it is a very small utf8 file I want to get a String out of.
of course if the library has a factored out way to read a utf8 file to String in less steps I'd use it.

The code at the end of what I have working is:

       {
            // create buffer to read into ( right kind best way to avoid copying ? )
            let array = Uint8Array::new_with_length((fsize as i32) as u32);

            // I need to create the right kind of "Object" fo pass in below
            // when the code runs I get a panic.  
            // ( not checking errors til it basically works for valid test case :)
            //
            let obj =  Object::new();
            // this is wrong should I call the field view ? or somethign else does it even matter ?
            Reflect::set(&obj, &"view".into(), &array);

            let promise = byob_reader.read_with_array_buffer_view(&obj);
        }

When this runs I get a panic:

TypeError: Failed to execute 'read' on 'ReadableStreamBYOBReader': parameter 1 is not of type 'ArrayBufferView'.

There is no struct ArrayBufferView in wasm_bindgen ( error might come from javascript ? )
Anyway trying to meke this happen.

Then I need to figure out what closure to pass int the promise in what way to ret the result !
Thanks.

Not sure if it helps but ArrayBufferView is a subclass of Uint8Array and many other array types. So you should be able to pass in any TypedArray from this list:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.