Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement FileReader.{readAsText,readAsDataUrl}. Fixes #6172 #6716

Merged
merged 1 commit into from Jul 23, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -9,6 +9,8 @@ use dom::bindings::utils::{Reflector, reflect_dom_object};
use dom::bindings::error::Fallible;
use dom::bindings::codegen::Bindings::BlobBinding;
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use std::sync::mpsc;
use std::sync::mpsc::Receiver;

use util::str::DOMString;

@@ -79,6 +81,22 @@ impl Blob {
}
}

pub trait BlobHelpers {
fn read_out_buffer(self) -> Receiver<Option<Vec<u8>>> ;
fn read_out_type(self) -> DOMString;
}

impl<'a> BlobHelpers for &'a Blob {
fn read_out_buffer(self) -> Receiver<Option<Vec<u8>>> {
let (send, recv) = mpsc::channel();
send.send(self.bytes.clone()).unwrap();
recv
}
fn read_out_type(self) -> DOMString {
self.typeString.clone()
}
}

impl<'a> BlobMethods for &'a Blob {
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-size
fn Size(self) -> u64{
@@ -48,6 +48,7 @@ pub enum EventTargetTypeId {
WebSocket,
Window,
Worker,
FileReader,
WorkerGlobalScope(WorkerGlobalScopeTypeId),
XMLHttpRequestEventTarget(XMLHttpRequestEventTargetTypeId)
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.