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/post-form.tsx | |
parent | e583e45d9a2221b3ed2a743cfa172abcd2a1d6a0 (diff) |
Fixing some front end pictshare to pictrs conversions.
Diffstat (limited to 'ui/src/components/post-form.tsx')
-rw-r--r-- | ui/src/components/post-form.tsx | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx index a9356d05..7811f918 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -520,7 +520,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> { const imageUploadUrl = `/pictrs/image`; const formData = new FormData(); - formData.append('images', file); + formData.append('images[]', file); i.state.imageLoading = true; i.setState(i.state); @@ -531,13 +531,19 @@ export class PostForm extends Component<PostFormProps, PostFormState> { }) .then(res => res.json()) .then(res => { - let url = `${window.location.origin}/pictrs/${encodeURI(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.postForm.url = url; + i.state.imageLoading = false; + i.setState(i.state); + } else { + i.state.imageLoading = false; + i.setState(i.state); + toast(JSON.stringify(res), 'danger'); } - i.state.postForm.url = url; - i.state.imageLoading = false; - i.setState(i.state); }) .catch(error => { i.state.imageLoading = false; |