mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-15 17:50:51 +00:00
Add Blob.stream() method (#2140)
This enables a ReadableStream to be obtained for a file, which can then be handled with e.g. https://github.com/MattiasBuelens/wasm-streams let file: web_sys::File = ...; let stream = wasm_streams::readable::ReadableStream::from( file.stream() .unchecked_into::<wasm_streams::readable::sys::ReadableStream>(), ); WebIDL source: https://w3c.github.io/FileAPI/#blob-section Docs: https://developer.mozilla.org/en-US/docs/Web/API/Blob/stream
This commit is contained in:
parent
adad1fbf41
commit
6ba8c6c2ec
@ -212,6 +212,14 @@ extern "C" {
|
|||||||
end: f64,
|
end: f64,
|
||||||
content_type: &str,
|
content_type: &str,
|
||||||
) -> Result<Blob, JsValue>;
|
) -> Result<Blob, JsValue>;
|
||||||
|
#[cfg(feature = "ReadableStream")]
|
||||||
|
# [ wasm_bindgen ( method , structural , js_class = "Blob" , js_name = stream ) ]
|
||||||
|
#[doc = "The `stream()` method."]
|
||||||
|
#[doc = ""]
|
||||||
|
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Blob/stream)"]
|
||||||
|
#[doc = ""]
|
||||||
|
#[doc = "*This API requires the following crate features to be activated: `Blob`, `ReadableStream`*"]
|
||||||
|
pub fn stream(this: &Blob) -> ReadableStream;
|
||||||
# [ wasm_bindgen ( method , structural , js_class = "Blob" , js_name = text ) ]
|
# [ wasm_bindgen ( method , structural , js_class = "Blob" , js_name = text ) ]
|
||||||
#[doc = "The `text()` method."]
|
#[doc = "The `text()` method."]
|
||||||
#[doc = ""]
|
#[doc = ""]
|
||||||
|
2
crates/web-sys/webidls/enabled/Blob.webidl
vendored
2
crates/web-sys/webidls/enabled/Blob.webidl
vendored
@ -29,6 +29,8 @@ interface Blob {
|
|||||||
[Clamp] optional long long end,
|
[Clamp] optional long long end,
|
||||||
optional DOMString contentType);
|
optional DOMString contentType);
|
||||||
|
|
||||||
|
// read from the Blob.
|
||||||
|
[NewObject] ReadableStream stream();
|
||||||
[NewObject] Promise<DOMString> text();
|
[NewObject] Promise<DOMString> text();
|
||||||
[NewObject] Promise<ArrayBuffer> arrayBuffer();
|
[NewObject] Promise<ArrayBuffer> arrayBuffer();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user