diff --git a/config/default.js b/config/default.js
index 559141b8..2868fdee 100644
--- a/config/default.js
+++ b/config/default.js
@@ -9,7 +9,7 @@ const {
SECRET_REDIS_PASSWORD = null,
SECRET_REDIS_TLS = false,
SECRET_JWT_SECRET = 'good_luck_have_fun',
- SECRET_DO_SPACES_ENDPOINT = 'https://ams3.digitaloceanspaces.com',
+ SECRET_DO_SPACES_ENDPOINT = 'https://fra1.digitaloceanspaces.com',
SECRET_DO_SPACES_KEY = '',
SECRET_DO_SPACES_SECRET = '',
SECRET_DO_SPACES_BUCKET = 'hemmelig',
diff --git a/src/client/config/default.js b/src/client/config/default.js
index 88fdea32..482995d9 100644
--- a/src/client/config/default.js
+++ b/src/client/config/default.js
@@ -2,4 +2,7 @@ export default {
api: {
host: 'http://localhost:3000/api',
},
+ settings: {
+ enableFileUpload: true,
+ },
};
diff --git a/src/client/routes/home/index.js b/src/client/routes/home/index.js
index cfca0108..34891680 100644
--- a/src/client/routes/home/index.js
+++ b/src/client/routes/home/index.js
@@ -17,6 +17,7 @@ import {
Text,
Collapse,
Divider,
+ FileButton,
} from '@mantine/core';
import {
IconSquarePlus,
@@ -30,19 +31,23 @@ import {
IconHeading,
} from '@tabler/icons';
+import config from '../../config';
+
import Error from '../../components/info/error';
-import { getToken } from '../../helpers/token';
+import { getToken, hasToken } from '../../helpers/token';
import { createSecret, burnSecret } from '../../api/secret';
const Home = () => {
const [text, setText] = useState('');
const [title, setTitle] = useState('');
-
+ const [enableFileUpload] = useState(config.get('settings.enableFileUpload', false));
+ const [file, setFile] = useState(null);
const [ttl, setTTL] = useState(14400);
const [password, setPassword] = useState('');
const [enablePassword, setOnEnablePassword] = useState(false);
+ const [isLoggedIn, setIsLoggedIn] = useState(hasToken() ? true : false);
const [allowedIp, setAllowedIp] = useState('');
const [preventBurn, setPreventBurn] = useState(false);
const [formData, setFormData] = useState(null);
@@ -116,6 +121,7 @@ const Home = () => {
setPassword('');
setEncryptionKey('');
setAllowedIp('');
+ setFile('');
setPreventBurn(false);
setFormData(new FormData());
};
@@ -130,7 +136,7 @@ const Home = () => {
event.preventDefault();
formData.append('text', text);
-
+ formData.append('file', file);
formData.append('title', title);
formData.append('password', password);
formData.append('ttl', ttl);
@@ -257,6 +263,47 @@ const Home = () => {
/>
+
+ {enableFileUpload && (
+
+ {(props) => (
+
+ )}
+
+ )}
+
+ {enableFileUpload && !isLoggedIn && (
+
+ Sign in to upload images
+
+ )}
+
+ {file && (
+
+ Picked file: {file.name}
+
+ )}
+
+