mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 09:39:15 +00:00
Use new Response(file).text() to obtain a binary string
This commit is contained in:
@@ -76,19 +76,18 @@ export default class App extends Component<Props, State> {
|
|||||||
files: [fileObj]
|
files: [fileObj]
|
||||||
});
|
});
|
||||||
|
|
||||||
let done = () => {
|
new Response(file).text()
|
||||||
|
.then(data => ({ data }))
|
||||||
|
.catch(error => ({ error }))
|
||||||
|
.then(state => {
|
||||||
|
console.log(state);
|
||||||
let files = this.state.files.slice();
|
let files = this.state.files.slice();
|
||||||
files[files.indexOf(fileObj)] = Object.assign({}, fileObj, {
|
files[files.indexOf(fileObj)] = Object.assign({}, fileObj, {
|
||||||
error: fr.error,
|
|
||||||
loading: false,
|
loading: false,
|
||||||
data: fr.result
|
...state
|
||||||
});
|
});
|
||||||
this.setState({ files });
|
this.setState({ files });
|
||||||
};
|
});
|
||||||
|
|
||||||
let fr = new FileReader();
|
|
||||||
fr.onerror = fr.onloadend = done;
|
|
||||||
fr.readAsDataURL(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render({ url }: Props, { showDrawer, showFab, files }: State) {
|
render({ url }: Props, { showDrawer, showFab, files }: State) {
|
||||||
|
|||||||
Reference in New Issue
Block a user