I met some trouble when I try to upload a file to ...
# javascript
u
I met some trouble when I try to upload a file to some OSS server. The console report ‘ClassCastException’ and I can’t cast a ArrayBuffer to Blob
t
reader.result as ArrayBuffer
?
u
Thank you for reply! But it doesn’t match.
ArrayBuffer
will be fine
As WA you can use:
Copy code
reader.result.unsafeCast<Array<dynamic>>()
It’s WA for missed
Blob
constructors
u
Thanks, there is no doubt that
reader.result.unsafeCast<Array<dynamic>>
is instance of
Array<dynamic>
, but Js can’t find the
@@iterator
property for
Array<dynamic>
Screen Shot 2022-08-31 at 18.15.29.png,Screen Shot 2022-08-31 at 18.16.23.png
t
Copy code
val buffer = reader.result as ArrayBuffer
val blob = Blob(arrayOf(buffer))
?
u
I think I got the Blob correctly. But maybe I need to read the Ktor document again to solve this serialized problem. Thank you!
😜 1
Screen Shot 2022-08-31 at 18.32.22.png,Screen Shot 2022-08-31 at 18.35.26.png