import { Component, linkEvent } from 'inferno';
+import { pictrsUri } from '../env';
import { UserService } from '../services';
import { toast, randomStr } from '../utils';
handleImageUpload(i: ImageUploadForm, event: any) {
event.preventDefault();
let file = event.target.files[0];
- const imageUploadUrl = `/pictrs/image`;
const formData = new FormData();
formData.append('images[]', file);
i.state.loading = true;
i.setState(i.state);
- fetch(imageUploadUrl, {
+ fetch(pictrsUri, {
method: 'POST',
body: formData,
})
console.log(res);
if (res.msg == 'ok') {
let hash = res.files[0].file;
- let url = `${window.location.origin}/pictrs/image/${hash}`;
+ let url = `${pictrsUri}/${hash}`;
i.state.loading = false;
i.setState(i.state);
i.props.onUpload(url);
import { UserService } from '../services';
import autosize from 'autosize';
import { i18n } from '../i18next';
+import { pictrsUri } from '../env';
interface MarkdownTextAreaProps {
initialContent: string;
file = event;
}
- const imageUploadUrl = `/pictrs/image`;
const formData = new FormData();
formData.append('images[]', file);
i.state.imageLoading = true;
i.setState(i.state);
- fetch(imageUploadUrl, {
+ fetch(pictrsUri, {
method: 'POST',
body: formData,
})
console.log(res);
if (res.msg == 'ok') {
let hash = res.files[0].file;
- let url = `${window.location.origin}/pictrs/image/${hash}`;
+ let url = `${pictrsUri}/${hash}`;
let deleteToken = res.files[0].delete_token;
- let deleteUrl = `${window.location.origin}/pictrs/image/delete/${deleteToken}/${hash}`;
+ let deleteUrl = `${pictrsUri}/delete/${deleteToken}/${hash}`;
let imageMarkdown = `![](${url})`;
let content = i.state.content;
content = content ? `${content}\n${imageMarkdown}` : imageMarkdown;
}
import { i18n } from '../i18next';
+import { pictrsUri } from '../env';
const MAX_POST_TITLE_LENGTH = 200;
file = event;
}
- const imageUploadUrl = `/pictrs/image`;
const formData = new FormData();
formData.append('images[]', file);
i.state.imageLoading = true;
i.setState(i.state);
- fetch(imageUploadUrl, {
+ fetch(pictrsUri, {
method: 'POST',
body: formData,
})
console.log(res);
if (res.msg == 'ok') {
let hash = res.files[0].file;
- let url = `${window.location.origin}/pictrs/image/${hash}`;
+ let url = `${pictrsUri}/${hash}`;
let deleteToken = res.files[0].delete_token;
- let deleteUrl = `${window.location.origin}/pictrs/image/delete/${deleteToken}/${hash}`;
+ let deleteUrl = `${pictrsUri}/delete/${deleteToken}/${hash}`;
i.state.postForm.url = url;
i.state.imageLoading = false;
i.setState(i.state);
export const wsUri = `ws${secure}://${endpoint}/api/v1/ws`;
export const httpUri = `http${secure}://${endpoint}/api/v1`;
+export const pictrsUri = `http${secure}://${endpoint}/pictrs/image`;