diff options
author | Dessalines <tyhou13@gmx.com> | 2020-06-09 17:17:24 -0400 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-06-09 17:17:24 -0400 |
commit | bd26e4e9c1b146163ee839de0a45bb9354efd1f2 (patch) | |
tree | 0c30425a32666f7597fb1d9362edcf199dc75a7d /ui/src/components/user.tsx | |
parent | e583e45d9a2221b3ed2a743cfa172abcd2a1d6a0 (diff) |
Fixing some front end pictshare to pictrs conversions.
Diffstat (limited to 'ui/src/components/user.tsx')
-rw-r--r-- | ui/src/components/user.tsx | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index c3b12fe0..833366a6 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -990,7 +990,7 @@ export class User extends Component<any, UserState> { let file = event.target.files[0]; const imageUploadUrl = `/pictrs/image`; const formData = new FormData(); - formData.append('file', file); + formData.append('images[]', file); i.state.avatarLoading = true; i.setState(i.state); @@ -1001,14 +1001,19 @@ export class User extends Component<any, UserState> { }) .then(res => res.json()) .then(res => { - let url = `${window.location.origin}/pictrs/${res.url}`; - if (res.filetype == 'mp4') { - url += '/raw'; + console.log('pictrs upload:'); + console.log(res); + if (res.msg == 'ok') { + let hash = res.files[0].file; + let url = `${window.location.origin}/pictrs/image/${hash}`; + i.state.userSettingsForm.avatar = url; + i.state.avatarLoading = false; + i.setState(i.state); + } else { + i.state.avatarLoading = false; + i.setState(i.state); + toast(JSON.stringify(res), 'danger'); } - i.state.userSettingsForm.avatar = url; - console.log(url); - i.state.avatarLoading = false; - i.setState(i.state); }) .catch(error => { i.state.avatarLoading = false; |