(
ctx: &Ctx<'js>,
data: Vec<u8>,
filename: String,
mime_type: Option<String>,
)
| 99 | |
| 100 | impl<'js> File<'js> { |
| 101 | pub fn from_bytes( |
| 102 | ctx: &Ctx<'js>, |
| 103 | data: Vec<u8>, |
| 104 | filename: String, |
| 105 | mime_type: Option<String>, |
| 106 | ) -> Result<Self> { |
| 107 | let options = Opt(Some({ |
| 108 | let obj = Object::new(ctx.clone())?; |
| 109 | obj.set("type", mime_type.clone().unwrap_or("".into()).into_js(ctx)?)?; |
| 110 | obj.into_js(ctx)? |
| 111 | })); |
| 112 | let blob = Blob::from_parts(ctx.clone(), Opt(Some(data.into_js(ctx)?)), options)?; |
| 113 | |
| 114 | Ok(Self { |
| 115 | blob, |
| 116 | filename, |
| 117 | last_modified: time::now_millis(), |
| 118 | }) |
| 119 | } |
| 120 | |
| 121 | pub fn get_blob(&self) -> Blob<'js> { |
| 122 | self.blob.clone() |
| 123 | } |
| 124 | |
| 125 | pub fn set_filename(&mut self, filename: String) { |
| 126 | self.filename = filename; |
| 127 | } |
| 128 | } |
nothing calls this directly
no test coverage detected