summaryrefslogtreecommitdiffstats
path: root/ui/src/components/user.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/components/user.tsx')
-rw-r--r--ui/src/components/user.tsx21
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;