Skip to content

Commit 7205838

Browse files
joshuadiezmoflovilmart
authored andcommitted
Fix upload json parse file (#935)
* Fix upload json parse file * add spaces between base64
1 parent 493ff19 commit 7205838

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/components/FileEditor/FileEditor.react.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,20 @@ export default class FileEditor extends React.Component {
4444
}
4545
}
4646

47-
handleChange(e) {
47+
getBase64(file){
48+
return new Promise((resolve, reject) => {
49+
const reader = new FileReader();
50+
reader.readAsDataURL(file);
51+
reader.onload = () => resolve(reader.result);
52+
reader.onerror = error => reject(error);
53+
});
54+
}
55+
56+
async handleChange(e) {
4857
let file = e.target.files[0];
4958
if (file) {
50-
this.props.onCommit(new Parse.File(file.name, file));
59+
let base64 = await this.getBase64(file);
60+
this.props.onCommit(new Parse.File(file.name, { base64 }));
5161
}
5262
}
5363

0 commit comments

Comments
 (0)