mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 17:49:52 +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]
|
||||
});
|
||||
|
||||
let done = () => {
|
||||
let files = this.state.files.slice();
|
||||
files[files.indexOf(fileObj)] = Object.assign({}, fileObj, {
|
||||
error: fr.error,
|
||||
loading: false,
|
||||
data: fr.result
|
||||
new Response(file).text()
|
||||
.then(data => ({ data }))
|
||||
.catch(error => ({ error }))
|
||||
.then(state => {
|
||||
console.log(state);
|
||||
let files = this.state.files.slice();
|
||||
files[files.indexOf(fileObj)] = Object.assign({}, fileObj, {
|
||||
loading: false,
|
||||
...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) {
|
||||
|
||||
Reference in New Issue
Block a user