init
This commit is contained in:
3
Backend/.gitattributes
vendored
Normal file
3
Backend/.gitattributes
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/gradlew text eol=lf
|
||||
*.bat text eol=crlf
|
||||
*.jar binary
|
||||
40
Backend/.gitignore
vendored
Normal file
40
Backend/.gitignore
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
HELP.md
|
||||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
build
|
||||
buildcompleted.at
|
||||
bin
|
||||
4
Backend/.ignore
Normal file
4
Backend/.ignore
Normal file
@@ -0,0 +1,4 @@
|
||||
.claude
|
||||
.gradle
|
||||
bin
|
||||
build
|
||||
43
Backend/build.gradle
Normal file
43
Backend/build.gradle
Normal file
@@ -0,0 +1,43 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '4.0.2'
|
||||
id 'org.graalvm.buildtools.native' version '0.11.1'
|
||||
id 'io.spring.dependency-management' version '1.1.7'
|
||||
}
|
||||
|
||||
group = 'com.gregor-lohaus'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
description = 'FOSS alternative to WeTransfer'
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(25)
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'org.webjars:webjars-locator-lite'
|
||||
implementation 'org.webjars.npm:htmx.org:2.0.4'
|
||||
implementation 'org.webjars.npm:bootstrap:5.3.3'
|
||||
runtimeOnly 'org.postgresql:postgresql'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
implementation 'io.github.wasabithumb:jtoml:1.4.2'
|
||||
implementation 'io.github.wasabithumb:jtoml-serializer-reflect:1.4.2'
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
tasks.build {
|
||||
dependsOn('processAot')
|
||||
dependsOn('nativeCompile')
|
||||
}
|
||||
BIN
Backend/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
Backend/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
Backend/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
Backend/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
248
Backend/gradlew
vendored
Executable file
248
Backend/gradlew
vendored
Executable file
@@ -0,0 +1,248 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
93
Backend/gradlew.bat
vendored
Normal file
93
Backend/gradlew.bat
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
1
Backend/settings.gradle
Normal file
1
Backend/settings.gradle
Normal file
@@ -0,0 +1 @@
|
||||
rootProject.name = 'gtransfer'
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.gregor_lohaus.gtransfer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.ConfigRuntimeHints;
|
||||
import com.gregor_lohaus.gtransfer.model.ModelRuntimeHints;
|
||||
import com.gregor_lohaus.gtransfer.native_image.HibernateRuntimeHints;
|
||||
import com.gregor_lohaus.gtransfer.native_image.WebRuntimeHints;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
@ImportRuntimeHints({ConfigRuntimeHints.class, HibernateRuntimeHints.class, ModelRuntimeHints.class, WebRuntimeHints.class})
|
||||
public class GtransferApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GtransferApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.gregor_lohaus.gtransfer.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import com.gregor_lohaus.gtransfer.config.types.Config;
|
||||
|
||||
import org.springframework.boot.EnvironmentPostProcessor;
|
||||
// import org.springframework.boot.env.EnvironmentPostProcessor;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
import io.github.wasabithumb.jtoml.JToml;
|
||||
import io.github.wasabithumb.jtoml.value.table.TomlTable;
|
||||
|
||||
public class ConfigEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
private static final Path CONFIG_FILE_PATH;
|
||||
static {
|
||||
Path sysPath = Paths.get("etc","gtransfer","config.toml");
|
||||
Path userPath = Paths.get(System.getProperty("user.home"),".config","gtransfer","config.toml");
|
||||
if (Files.isReadable(sysPath) && !Files.isReadable(userPath)) {
|
||||
CONFIG_FILE_PATH = sysPath;
|
||||
} else {
|
||||
CONFIG_FILE_PATH = userPath;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
JToml toml = JToml.jToml();
|
||||
TomlTable table;
|
||||
if (Files.isReadable(CONFIG_FILE_PATH)) {
|
||||
table = toml.read(CONFIG_FILE_PATH);
|
||||
} else {
|
||||
try {
|
||||
Files.createDirectories(CONFIG_FILE_PATH.getParent());
|
||||
Files.createFile(CONFIG_FILE_PATH);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
Config defaultConfig = DefaultConfig.config;
|
||||
table = ConfigSerializer.toToml(defaultConfig);
|
||||
toml.write(CONFIG_FILE_PATH, table);
|
||||
}
|
||||
;
|
||||
Config config = new Config();
|
||||
config = ConfigSerializer.fromToml(table);
|
||||
ReflectionPropertySource<Config> source = new ReflectionPropertySource<Config>("gtransfer-config", config);
|
||||
environment.getPropertySources()
|
||||
.addLast(source);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.gregor_lohaus.gtransfer.config;
|
||||
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import com.gregor_lohaus.gtransfer.config.types.*;
|
||||
|
||||
import io.github.wasabithumb.jtoml.serial.reflect.adapter.TypeAdapter;
|
||||
|
||||
public class ConfigRuntimeHints implements RuntimeHintsRegistrar {
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerType(Config.class,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.ACCESS_DECLARED_FIELDS,
|
||||
MemberCategory.ACCESS_PUBLIC_FIELDS);
|
||||
hints.reflection().registerType(StorageService.class,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.ACCESS_DECLARED_FIELDS,
|
||||
MemberCategory.ACCESS_PUBLIC_FIELDS);
|
||||
hints.reflection().registerType(StorageServiceType.class,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.ACCESS_DECLARED_FIELDS,
|
||||
MemberCategory.ACCESS_PUBLIC_FIELDS);
|
||||
hints.reflection().registerType(SpringConfig.class,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.ACCESS_DECLARED_FIELDS,
|
||||
MemberCategory.ACCESS_PUBLIC_FIELDS);
|
||||
hints.reflection().registerType(JpaConfig.class,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.ACCESS_DECLARED_FIELDS,
|
||||
MemberCategory.ACCESS_PUBLIC_FIELDS);
|
||||
hints.reflection().registerType(DataSourceConfig.class,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.ACCESS_DECLARED_FIELDS,
|
||||
MemberCategory.ACCESS_PUBLIC_FIELDS);
|
||||
hints.reflection().registerType(ServletConfig.class,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.ACCESS_DECLARED_FIELDS,
|
||||
MemberCategory.ACCESS_PUBLIC_FIELDS);
|
||||
hints.reflection().registerType(MultipartConfig.class,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.ACCESS_DECLARED_FIELDS,
|
||||
MemberCategory.ACCESS_PUBLIC_FIELDS);
|
||||
hints.reflection().registerType(TypeAdapter.class,
|
||||
MemberCategory.ACCESS_DECLARED_FIELDS,
|
||||
MemberCategory.ACCESS_PUBLIC_FIELDS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.gregor_lohaus.gtransfer.config;
|
||||
|
||||
import io.github.wasabithumb.jtoml.serial.reflect.ReflectTomlSerializer;
|
||||
import io.github.wasabithumb.jtoml.serial.reflect.adapter.TypeAdapter;
|
||||
import io.github.wasabithumb.jtoml.serial.reflect.adapter.TypeAdapters;
|
||||
import io.github.wasabithumb.jtoml.value.TomlValue;
|
||||
import io.github.wasabithumb.jtoml.value.table.TomlTable;
|
||||
import com.gregor_lohaus.gtransfer.config.types.Config;
|
||||
import com.gregor_lohaus.gtransfer.config.types.StorageServiceType;
|
||||
|
||||
public class ConfigSerializer {
|
||||
static final private ReflectTomlSerializer<Config> s;
|
||||
static {
|
||||
TypeAdapter<StorageServiceType> fileWritTypeAdapter = TypeAdapter.of(
|
||||
StorageServiceType.class,
|
||||
(TomlValue v) -> StorageServiceType.fromToml(v),
|
||||
(StorageServiceType f) -> StorageServiceType.toToml(f)
|
||||
);
|
||||
TypeAdapters typeAdapters = TypeAdapters.builder()
|
||||
.add(TypeAdapters.standard())
|
||||
.add(fileWritTypeAdapter)
|
||||
.build();
|
||||
s = new ReflectTomlSerializer<Config>(Config.class,typeAdapters);
|
||||
}
|
||||
|
||||
public static Config fromToml(TomlTable t) {
|
||||
return s.fromToml(t);
|
||||
}
|
||||
|
||||
public static TomlTable toToml(Config c) {
|
||||
return s.toToml(c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gregor_lohaus.gtransfer.config;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.types.Config;
|
||||
import com.gregor_lohaus.gtransfer.config.types.DataSourceConfig;
|
||||
import com.gregor_lohaus.gtransfer.config.types.JpaConfig;
|
||||
import com.gregor_lohaus.gtransfer.config.types.MultipartConfig;
|
||||
import com.gregor_lohaus.gtransfer.config.types.ServletConfig;
|
||||
import com.gregor_lohaus.gtransfer.config.types.SpringConfig;
|
||||
import com.gregor_lohaus.gtransfer.config.types.StorageService;
|
||||
import com.gregor_lohaus.gtransfer.config.types.StorageServiceType;
|
||||
|
||||
public class DefaultConfig {
|
||||
public static final Config config;
|
||||
static {
|
||||
Config c = new Config();
|
||||
|
||||
StorageService ss = new StorageService();
|
||||
ss.type = StorageServiceType.LOCAL;
|
||||
ss.path = Path.of(System.getProperty("user.home"),".local","share","gtransfer").toString();
|
||||
c.storageService= ss;
|
||||
|
||||
SpringConfig sc = new SpringConfig();
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.password = "gtransfer";
|
||||
dsc.url = "jdbc:postgresql://localhost:5432/gtransfer";
|
||||
dsc.username = "gtransfer";
|
||||
sc.dataSourceConfig = dsc;
|
||||
|
||||
JpaConfig jc = new JpaConfig();
|
||||
jc.ddlAuto = "update";
|
||||
jc.dialect = "org.hibernate.dialect.PostgreSQLDialect";
|
||||
jc.showSql = true;
|
||||
sc.jpaConfig = jc;
|
||||
|
||||
MultipartConfig mc = new MultipartConfig();
|
||||
mc.maxFileSize = "10GB";
|
||||
mc.maxRequestSize = "10GB";
|
||||
ServletConfig svc = new ServletConfig();
|
||||
svc.multipartConfig = mc;
|
||||
sc.servletConfig = svc;
|
||||
|
||||
c.springConfig = sc;
|
||||
config = c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.gregor_lohaus.gtransfer.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.Named;
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.Nested;
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.NoPrefix;
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.Property;
|
||||
|
||||
public class ReflectionPropertySource<T> extends PropertySource<T> {
|
||||
private HashMap<String, Object> fields;
|
||||
private ArrayList<String> propNameBuffer;
|
||||
|
||||
public ReflectionPropertySource(String name, T source) {
|
||||
super(name);
|
||||
this.fields = new HashMap<String, Object>();
|
||||
this.propNameBuffer = new ArrayList<String>();
|
||||
this.propNameBuffer.add(this.getName());
|
||||
this.getFields(source, 0);
|
||||
}
|
||||
|
||||
private boolean hasPrefix() {
|
||||
if (propNameBuffer.size() > 0 && propNameBuffer.getFirst() == this.getName()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleNoPrefix(Field field) {
|
||||
NoPrefix np = field.getAnnotation(NoPrefix.class);
|
||||
if (np != null && this.hasPrefix()) {
|
||||
this.propNameBuffer.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleAnnotated(Field field, Object object, int depth) throws IllegalAccessException {
|
||||
Annotation annotation;
|
||||
annotation = field.getAnnotation(Property.class);
|
||||
if (annotation == null) {
|
||||
annotation = field.getAnnotation(Nested.class);
|
||||
}
|
||||
Optional<String> name = Named.nameOf(annotation);
|
||||
if (name.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
field.setAccessible(true);
|
||||
Object fieldValue = field.get(object);
|
||||
if (fieldValue == null) {
|
||||
return;
|
||||
}
|
||||
handleNoPrefix(field);
|
||||
propNameBuffer.add(name.get());
|
||||
switch (annotation) {
|
||||
case Nested _ -> getFields(fieldValue, depth + 1);
|
||||
case Property _ -> fields.put(String.join(".", propNameBuffer), fieldValue);
|
||||
case null -> {}
|
||||
default -> {}
|
||||
}
|
||||
propNameBuffer.removeLast();
|
||||
}
|
||||
|
||||
private void getFields(Object object, int depth) {
|
||||
Class<?> c = object.getClass();
|
||||
Field[] fields = c.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
handleAnnotated(field, object, depth);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
if (depth == 0 && !hasPrefix()) {
|
||||
propNameBuffer.addFirst(this.getName());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public @Nullable Object getProperty(String name) {
|
||||
return this.fields.get(name);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder out = new StringBuilder();
|
||||
this.fields.forEach((String f, Object o) -> {
|
||||
out.append(f + ":" + o.toString() + "\n");
|
||||
});
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.gregor_lohaus.gtransfer.config.annotations;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface Named {
|
||||
static Optional<String> nameOf(Annotation annotation) {
|
||||
return switch (annotation) {
|
||||
case Property p -> Optional.of(p.name());
|
||||
case Nested n -> Optional.of(n.name());
|
||||
case null -> Optional.empty();
|
||||
default -> Optional.empty();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gregor_lohaus.gtransfer.config.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Nested {
|
||||
String name() default "";
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.gregor_lohaus.gtransfer.config.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface NoPrefix {}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gregor_lohaus.gtransfer.config.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Property {
|
||||
String name() default "";
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.gregor_lohaus.gtransfer.config.types;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.Nested;
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.NoPrefix;
|
||||
|
||||
import io.github.wasabithumb.jtoml.serial.TomlSerializable;
|
||||
|
||||
public class Config implements TomlSerializable {
|
||||
@Nested(name = "spring")
|
||||
@NoPrefix
|
||||
public SpringConfig springConfig;
|
||||
@Nested(name = "storageService")
|
||||
public StorageService storageService;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.gregor_lohaus.gtransfer.config.types;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.Property;
|
||||
|
||||
import io.github.wasabithumb.jtoml.serial.TomlSerializable;
|
||||
|
||||
public class DataSourceConfig implements TomlSerializable {
|
||||
@Property(name = "url")
|
||||
public String url;
|
||||
@Property(name = "username")
|
||||
public String username;
|
||||
@Property(name = "password")
|
||||
public String password;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.gregor_lohaus.gtransfer.config.types;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.Property;
|
||||
|
||||
import io.github.wasabithumb.jtoml.serial.TomlSerializable;
|
||||
|
||||
public class JpaConfig implements TomlSerializable {
|
||||
@Property(name = "hibernate.ddl-auto")
|
||||
public String ddlAuto;
|
||||
@Property(name = "show-sql")
|
||||
public boolean showSql;
|
||||
@Property(name = "properties.hibernate.dialect")
|
||||
public String dialect;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gregor_lohaus.gtransfer.config.types;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.Property;
|
||||
|
||||
import io.github.wasabithumb.jtoml.serial.TomlSerializable;
|
||||
|
||||
public class MultipartConfig implements TomlSerializable {
|
||||
@Property(name = "max-file-size")
|
||||
public String maxFileSize;
|
||||
@Property(name = "max-request-size")
|
||||
public String maxRequestSize;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.gregor_lohaus.gtransfer.config.types;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.Nested;
|
||||
|
||||
import io.github.wasabithumb.jtoml.serial.TomlSerializable;
|
||||
|
||||
public class ServletConfig implements TomlSerializable {
|
||||
@Nested(name = "multipart")
|
||||
public MultipartConfig multipartConfig;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.gregor_lohaus.gtransfer.config.types;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.Nested;
|
||||
|
||||
import io.github.wasabithumb.jtoml.serial.TomlSerializable;
|
||||
|
||||
public class SpringConfig implements TomlSerializable {
|
||||
@Nested(name = "datasource")
|
||||
public DataSourceConfig dataSourceConfig;
|
||||
@Nested(name = "jpa")
|
||||
public JpaConfig jpaConfig;
|
||||
@Nested(name = "servlet")
|
||||
public ServletConfig servletConfig;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gregor_lohaus.gtransfer.config.types;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.annotations.Property;
|
||||
|
||||
import io.github.wasabithumb.jtoml.serial.TomlSerializable;
|
||||
|
||||
public class StorageService implements TomlSerializable {
|
||||
@Property(name = "type")
|
||||
public StorageServiceType type;
|
||||
@Property(name = "root")
|
||||
public String path;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.gregor_lohaus.gtransfer.config.types;
|
||||
|
||||
import io.github.wasabithumb.jtoml.serial.TomlSerializable;
|
||||
import io.github.wasabithumb.jtoml.value.TomlValue;
|
||||
import io.github.wasabithumb.jtoml.value.primitive.TomlPrimitive;;
|
||||
public enum StorageServiceType implements TomlSerializable {
|
||||
LOCAL,
|
||||
S3,
|
||||
DUMMY;
|
||||
public static StorageServiceType fromToml(TomlValue value) {
|
||||
return switch (value.asPrimitive().asString().toLowerCase()) {
|
||||
case "dummy" -> DUMMY;
|
||||
case "local" -> LOCAL;
|
||||
case "s3" -> S3;
|
||||
default -> throw new IllegalArgumentException("couldnt parse filewriter type");
|
||||
};
|
||||
}
|
||||
public static TomlValue toToml(StorageServiceType t) {
|
||||
return switch (t) {
|
||||
case LOCAL -> TomlPrimitive.of("local");
|
||||
case S3 -> TomlPrimitive.of("s3");
|
||||
case DUMMY -> TomlPrimitive.of("dummy");
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.gregor_lohaus.gtransfer.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.services.filewriter.AbstractStorageService;
|
||||
|
||||
@RestController
|
||||
public class Env {
|
||||
@Autowired
|
||||
private ConfigurableEnvironment env;
|
||||
@Autowired
|
||||
private AbstractStorageService storageService;
|
||||
@GetMapping("/env")
|
||||
public String env() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
MutablePropertySources sources = this.env.getPropertySources();
|
||||
sources.forEach((var m) -> {
|
||||
b.append(m.toString());
|
||||
b.append("\n");
|
||||
});
|
||||
b.append(storageService.getClass().toString());
|
||||
return b.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.gregor_lohaus.gtransfer.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class IndexController {
|
||||
|
||||
@Value("${spring.servlet.multipart.max-file-size:10GB}")
|
||||
private String maxFileSize;
|
||||
|
||||
@GetMapping("/")
|
||||
public String index(Model model) {
|
||||
model.addAttribute("maxFileSize", maxFileSize);
|
||||
return "index";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gregor_lohaus.gtransfer.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.model.File;
|
||||
import com.gregor_lohaus.gtransfer.model.FileRepository;
|
||||
import com.gregor_lohaus.gtransfer.services.filewriter.AbstractStorageService;
|
||||
|
||||
@RestController
|
||||
public class UploadController {
|
||||
|
||||
@Autowired
|
||||
private AbstractStorageService storageService;
|
||||
|
||||
@Autowired
|
||||
private FileRepository fileRepository;
|
||||
|
||||
@PostMapping("/upload")
|
||||
public ResponseEntity<Map<String, String>> upload(
|
||||
@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("hash") String hash,
|
||||
@RequestParam("name") String name) throws IOException {
|
||||
|
||||
storageService.put(hash, file.getBytes());
|
||||
fileRepository.save(new File(hash, hash, name, null));
|
||||
|
||||
return ResponseEntity.ok(Map.of("id", hash));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.gregor_lohaus.gtransfer.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "files")
|
||||
public class File {
|
||||
protected File() {}
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
private String path;
|
||||
private String name;
|
||||
private LocalDateTime expireyDateTime;
|
||||
private Integer downloadLimit;
|
||||
public LocalDateTime getExpireyDateTime() {
|
||||
return expireyDateTime;
|
||||
}
|
||||
public void setExpireyDateTime(LocalDateTime expireyDateTime) {
|
||||
this.expireyDateTime = expireyDateTime;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public Integer getDownloadLimit() {
|
||||
return downloadLimit;
|
||||
}
|
||||
public void setDownloadLimit(Integer downloadLimit) {
|
||||
this.downloadLimit = downloadLimit;
|
||||
}
|
||||
public File(String id, String path, String name, LocalDateTime expDateTime) {
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.expireyDateTime = expDateTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.gregor_lohaus.gtransfer.model;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface FileRepository extends JpaRepository<File, String> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.gregor_lohaus.gtransfer.model;
|
||||
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
|
||||
public class ModelRuntimeHints implements RuntimeHintsRegistrar {
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerType(File.class,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.ACCESS_DECLARED_FIELDS,
|
||||
MemberCategory.INVOKE_DECLARED_METHODS,
|
||||
MemberCategory.INVOKE_PUBLIC_METHODS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.gregor_lohaus.gtransfer.native_image;
|
||||
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
|
||||
public class HibernateRuntimeHints implements RuntimeHintsRegistrar {
|
||||
private static final String[] LOGGER_IMPLEMENTATIONS = {
|
||||
"org.hibernate.jpa.internal.JpaLogger_$logger",
|
||||
"org.hibernate.internal.CoreMessageLogger_$logger",
|
||||
"org.hibernate.internal.log.DeprecationLogger_$logger",
|
||||
"org.hibernate.internal.log.IncubationLogger_$logger",
|
||||
"org.hibernate.internal.log.ConnectionAccessLogger_$logger",
|
||||
"org.hibernate.internal.log.ConnectionInfoLogger_$logger",
|
||||
"org.hibernate.internal.log.StatisticsLogger_$logger",
|
||||
"org.hibernate.internal.log.UrlMessageBundle_$logger",
|
||||
"org.hibernate.internal.SessionFactoryLogging_$logger",
|
||||
"org.hibernate.internal.SessionFactoryRegistryMessageLogger_$logger",
|
||||
"org.hibernate.internal.SessionLogging_$logger",
|
||||
"org.hibernate.boot.BootLogging_$logger",
|
||||
"org.hibernate.boot.archive.scan.internal.ScannerLogger_$logger",
|
||||
"org.hibernate.boot.beanvalidation.BeanValidationLogger_$logger",
|
||||
"org.hibernate.boot.jaxb.JaxbLogger_$logger",
|
||||
"org.hibernate.dialect.DialectLogging_$logger",
|
||||
"org.hibernate.engine.jdbc.JdbcLogging_$logger",
|
||||
"org.hibernate.engine.jdbc.batch.JdbcBatchLogging_$logger",
|
||||
"org.hibernate.engine.jdbc.connections.internal.ConnectionProviderLogging_$logger",
|
||||
"org.hibernate.engine.jdbc.env.internal.LobCreationLogging_$logger",
|
||||
"org.hibernate.engine.jdbc.spi.SQLExceptionLogging_$logger",
|
||||
"org.hibernate.engine.internal.NaturalIdLogging_$logger",
|
||||
"org.hibernate.engine.internal.PersistenceContextLogging_$logger",
|
||||
"org.hibernate.engine.internal.SessionMetricsLogger_$logger",
|
||||
"org.hibernate.engine.internal.VersionLogger_$logger",
|
||||
"org.hibernate.resource.jdbc.internal.LogicalConnectionLogging_$logger",
|
||||
"org.hibernate.resource.jdbc.internal.ResourceRegistryLogger_$logger",
|
||||
"org.hibernate.resource.transaction.internal.SynchronizationLogging_$logger",
|
||||
"org.hibernate.resource.transaction.backend.jta.internal.JtaLogging_$logger",
|
||||
"org.hibernate.resource.beans.internal.BeansMessageLogger_$logger",
|
||||
"org.hibernate.service.internal.ServiceLogger_$logger",
|
||||
"org.hibernate.sql.ast.tree.SqlAstTreeLogger_$logger",
|
||||
"org.hibernate.sql.exec.SqlExecLogger_$logger",
|
||||
"org.hibernate.sql.model.ModelMutationLogging_$logger",
|
||||
"org.hibernate.sql.results.LoadingLogger_$logger",
|
||||
"org.hibernate.sql.results.ResultsLogger_$logger",
|
||||
"org.hibernate.sql.results.graph.embeddable.EmbeddableLoadingLogger_$logger",
|
||||
"org.hibernate.query.QueryLogging_$logger",
|
||||
"org.hibernate.query.hql.HqlLogging_$logger",
|
||||
"org.hibernate.id.UUIDLogger_$logger",
|
||||
"org.hibernate.id.enhanced.OptimizerLogger_$logger",
|
||||
"org.hibernate.id.enhanced.SequenceGeneratorLogger_$logger",
|
||||
"org.hibernate.id.enhanced.TableGeneratorLogger_$logger",
|
||||
"org.hibernate.action.internal.ActionLogging_$logger",
|
||||
"org.hibernate.cache.spi.SecondLevelCacheLogger_$logger",
|
||||
"org.hibernate.collection.internal.CollectionLogger_$logger",
|
||||
"org.hibernate.context.internal.CurrentSessionLogging_$logger",
|
||||
"org.hibernate.event.internal.EntityCopyLogging_$logger",
|
||||
"org.hibernate.event.internal.EventListenerLogging_$logger",
|
||||
"org.hibernate.loader.ast.internal.MultiKeyLoadLogging_$logger",
|
||||
"org.hibernate.metamodel.mapping.MappingModelCreationLogging_$logger",
|
||||
"org.hibernate.bytecode.enhance.internal.BytecodeEnhancementLogging_$logger",
|
||||
"org.hibernate.bytecode.enhance.spi.interceptor.BytecodeInterceptorLogging_$logger",
|
||||
};
|
||||
|
||||
private static final Class<?>[] EVENT_LISTENER_TYPES = {
|
||||
org.hibernate.event.spi.AutoFlushEventListener.class,
|
||||
org.hibernate.event.spi.ClearEventListener.class,
|
||||
org.hibernate.event.spi.DeleteEventListener.class,
|
||||
org.hibernate.event.spi.DirtyCheckEventListener.class,
|
||||
org.hibernate.event.spi.EvictEventListener.class,
|
||||
org.hibernate.event.spi.FlushEntityEventListener.class,
|
||||
org.hibernate.event.spi.FlushEventListener.class,
|
||||
org.hibernate.event.spi.InitializeCollectionEventListener.class,
|
||||
org.hibernate.event.spi.LoadEventListener.class,
|
||||
org.hibernate.event.spi.LockEventListener.class,
|
||||
org.hibernate.event.spi.MergeEventListener.class,
|
||||
org.hibernate.event.spi.PersistEventListener.class,
|
||||
org.hibernate.event.spi.PostCollectionRecreateEventListener.class,
|
||||
org.hibernate.event.spi.PostCollectionRemoveEventListener.class,
|
||||
org.hibernate.event.spi.PostCollectionUpdateEventListener.class,
|
||||
org.hibernate.event.spi.PostCommitDeleteEventListener.class,
|
||||
org.hibernate.event.spi.PostCommitInsertEventListener.class,
|
||||
org.hibernate.event.spi.PostCommitUpdateEventListener.class,
|
||||
org.hibernate.event.spi.PostDeleteEventListener.class,
|
||||
org.hibernate.event.spi.PostInsertEventListener.class,
|
||||
org.hibernate.event.spi.PostLoadEventListener.class,
|
||||
org.hibernate.event.spi.PostUpdateEventListener.class,
|
||||
org.hibernate.event.spi.PostUpsertEventListener.class,
|
||||
org.hibernate.event.spi.PreCollectionRecreateEventListener.class,
|
||||
org.hibernate.event.spi.PreCollectionRemoveEventListener.class,
|
||||
org.hibernate.event.spi.PreCollectionUpdateEventListener.class,
|
||||
org.hibernate.event.spi.PreDeleteEventListener.class,
|
||||
org.hibernate.event.spi.PreFlushEventListener.class,
|
||||
org.hibernate.event.spi.PreInsertEventListener.class,
|
||||
org.hibernate.event.spi.PreLoadEventListener.class,
|
||||
org.hibernate.event.spi.PreUpdateEventListener.class,
|
||||
org.hibernate.event.spi.PreUpsertEventListener.class,
|
||||
org.hibernate.event.spi.RefreshEventListener.class,
|
||||
org.hibernate.event.spi.ReplicateEventListener.class,
|
||||
};
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
for (String logger : LOGGER_IMPLEMENTATIONS) {
|
||||
hints.reflection().registerTypeIfPresent(classLoader, logger,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_DECLARED_METHODS,
|
||||
MemberCategory.INVOKE_PUBLIC_METHODS);
|
||||
}
|
||||
|
||||
for (Class<?> listenerType : EVENT_LISTENER_TYPES) {
|
||||
hints.reflection().registerType(
|
||||
listenerType.arrayType(),
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
}
|
||||
|
||||
hints.reflection().registerTypeIfPresent(classLoader,
|
||||
"org.hibernate.event.spi.PostActionEventListener[]",
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gregor_lohaus.gtransfer.native_image;
|
||||
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
|
||||
public class WebRuntimeHints implements RuntimeHintsRegistrar {
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.resources().registerPattern("templates/**");
|
||||
hints.resources().registerPattern("static/**");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.gregor_lohaus.gtransfer.services.filewriter;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
public abstract class AbstractStorageService {
|
||||
protected Path root;
|
||||
|
||||
public AbstractStorageService(Path root) {
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
abstract public OptionalLong put(String id, byte[] data);
|
||||
abstract public Optional<byte[]> get(String id);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.gregor_lohaus.gtransfer.services.filewriter;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
public class DummyStorageService extends AbstractStorageService {
|
||||
|
||||
public DummyStorageService(Path root) {
|
||||
super(root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptionalLong put(String id, byte[] data) {
|
||||
return OptionalLong.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<byte[]> get(String id) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.gregor_lohaus.gtransfer.services.filewriter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
public class LocalStorageService extends AbstractStorageService {
|
||||
|
||||
public LocalStorageService(Path root) {
|
||||
super(root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptionalLong put(String id, byte[] data) {
|
||||
try {
|
||||
Files.createDirectories(root);
|
||||
Files.write(root.resolve(id), data);
|
||||
return OptionalLong.of(data.length);
|
||||
} catch (IOException e) {
|
||||
return OptionalLong.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<byte[]> get(String id) {
|
||||
try {
|
||||
Path target = root.resolve(id);
|
||||
if (!Files.exists(target)) return Optional.empty();
|
||||
return Optional.of(Files.readAllBytes(target));
|
||||
} catch (IOException e) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.gregor_lohaus.gtransfer.services.filewriter;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.gregor_lohaus.gtransfer.config.types.StorageServiceType;
|
||||
|
||||
@Configuration
|
||||
public class StorageServiceConfiguration {
|
||||
|
||||
//TODO S3 implementation
|
||||
@Bean
|
||||
public AbstractStorageService storageService(
|
||||
@Value("${gtransfer-config.storageService.type}") StorageServiceType type,
|
||||
@Value("${gtransfer-config.storageService.root}") String root) {
|
||||
return switch (type) {
|
||||
case LOCAL -> new LocalStorageService(Path.of(root));
|
||||
case DUMMY -> new DummyStorageService(Path.of(root));
|
||||
case S3 -> new LocalStorageService(Path.of(root));
|
||||
};
|
||||
}
|
||||
}
|
||||
1
Backend/src/main/resources/META-INF/spring.factories
Normal file
1
Backend/src/main/resources/META-INF/spring.factories
Normal file
@@ -0,0 +1 @@
|
||||
org.springframework.boot.EnvironmentPostProcessor=com.gregor_lohaus.gtransfer.config.ConfigEnvironmentPostProcessor
|
||||
1
Backend/src/main/resources/application.properties
Normal file
1
Backend/src/main/resources/application.properties
Normal file
@@ -0,0 +1 @@
|
||||
spring.application.name=gtransfer
|
||||
67
Backend/src/main/resources/static/style.css
Normal file
67
Backend/src/main/resources/static/style.css
Normal file
@@ -0,0 +1,67 @@
|
||||
body {
|
||||
background-color: #0d1117;
|
||||
color: #e6edf3;
|
||||
}
|
||||
|
||||
.brand {
|
||||
letter-spacing: -0.5px;
|
||||
color: #e6edf3;
|
||||
}
|
||||
.brand span {
|
||||
color: #3fb950;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 3rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -1px;
|
||||
line-height: 1.1;
|
||||
}
|
||||
.hero-title span {
|
||||
color: #3fb950;
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
color: #8b949e;
|
||||
max-width: 480px;
|
||||
}
|
||||
|
||||
.drop-zone {
|
||||
border: 2px dashed #30363d;
|
||||
border-radius: 16px;
|
||||
background-color: #161b22;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s, background-color 0.2s;
|
||||
max-width: 520px;
|
||||
}
|
||||
.drop-zone:hover,
|
||||
.drop-zone.dragover {
|
||||
border-color: #3fb950;
|
||||
background-color: #0d1117;
|
||||
}
|
||||
|
||||
.drop-zone-icon {
|
||||
font-size: 2.5rem;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.drop-zone-text {
|
||||
color: #8b949e;
|
||||
}
|
||||
.drop-zone-text strong {
|
||||
color: #3fb950;
|
||||
}
|
||||
|
||||
.badge-e2e {
|
||||
background-color: #1a2f1e;
|
||||
color: #3fb950;
|
||||
border: 1px solid #2ea043;
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
footer, footer a {
|
||||
color: #484f58;
|
||||
}
|
||||
footer a:hover {
|
||||
color: #8b949e;
|
||||
}
|
||||
135
Backend/src/main/resources/static/upload.js
Normal file
135
Backend/src/main/resources/static/upload.js
Normal file
@@ -0,0 +1,135 @@
|
||||
const dropZone = document.getElementById('drop-zone');
|
||||
const fileInput = document.getElementById('file-input');
|
||||
|
||||
const views = {
|
||||
prompt: document.getElementById('view-prompt'),
|
||||
selected: document.getElementById('view-selected'),
|
||||
uploading: document.getElementById('view-uploading'),
|
||||
result: document.getElementById('view-result'),
|
||||
};
|
||||
|
||||
let selectedFile = null;
|
||||
|
||||
function showView(name) {
|
||||
Object.entries(views).forEach(([key, el]) => el.classList.toggle('d-none', key !== name));
|
||||
}
|
||||
|
||||
// ── File selection ────────────────────────────────────────────────────────────
|
||||
|
||||
dropZone.addEventListener('click', () => {
|
||||
if (views.prompt.classList.contains('d-none')) return;
|
||||
fileInput.click();
|
||||
});
|
||||
|
||||
fileInput.addEventListener('change', e => {
|
||||
if (e.target.files[0]) selectFile(e.target.files[0]);
|
||||
});
|
||||
|
||||
dropZone.addEventListener('dragover', e => {
|
||||
e.preventDefault();
|
||||
dropZone.classList.add('dragover');
|
||||
});
|
||||
|
||||
dropZone.addEventListener('dragleave', () => dropZone.classList.remove('dragover'));
|
||||
|
||||
dropZone.addEventListener('drop', e => {
|
||||
e.preventDefault();
|
||||
dropZone.classList.remove('dragover');
|
||||
if (e.dataTransfer.files[0]) selectFile(e.dataTransfer.files[0]);
|
||||
});
|
||||
|
||||
function selectFile(file) {
|
||||
selectedFile = file;
|
||||
document.getElementById('selected-name').textContent = file.name;
|
||||
showView('selected');
|
||||
}
|
||||
|
||||
document.getElementById('reset-btn').addEventListener('click', e => {
|
||||
e.stopPropagation();
|
||||
selectedFile = null;
|
||||
fileInput.value = '';
|
||||
showView('prompt');
|
||||
});
|
||||
|
||||
document.getElementById('new-upload-btn').addEventListener('click', e => {
|
||||
e.stopPropagation();
|
||||
selectedFile = null;
|
||||
fileInput.value = '';
|
||||
showView('prompt');
|
||||
});
|
||||
|
||||
// ── Upload ────────────────────────────────────────────────────────────────────
|
||||
|
||||
document.getElementById('upload-btn').addEventListener('click', async e => {
|
||||
e.stopPropagation();
|
||||
await upload();
|
||||
});
|
||||
|
||||
function setStatus(msg) {
|
||||
document.getElementById('upload-status').textContent = msg;
|
||||
}
|
||||
|
||||
async function upload() {
|
||||
const file = selectedFile;
|
||||
showView('uploading');
|
||||
|
||||
try {
|
||||
setStatus('Generating encryption key\u2026');
|
||||
const key = await crypto.subtle.generateKey(
|
||||
{ name: 'AES-GCM', length: 256 },
|
||||
true,
|
||||
['encrypt', 'decrypt']
|
||||
);
|
||||
|
||||
const iv = crypto.getRandomValues(new Uint8Array(12));
|
||||
|
||||
setStatus('Encrypting\u2026');
|
||||
const ciphertext = await crypto.subtle.encrypt(
|
||||
{ name: 'AES-GCM', iv },
|
||||
key,
|
||||
await file.arrayBuffer()
|
||||
);
|
||||
|
||||
// Payload: 12-byte IV prepended to ciphertext
|
||||
const payload = new Uint8Array(12 + ciphertext.byteLength);
|
||||
payload.set(iv, 0);
|
||||
payload.set(new Uint8Array(ciphertext), 12);
|
||||
|
||||
// SHA-256(rawKey) → file identifier sent to server (server never sees the key)
|
||||
const rawKey = await crypto.subtle.exportKey('raw', key);
|
||||
const hash = Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256', rawKey)))
|
||||
.map(b => b.toString(16).padStart(2, '0'))
|
||||
.join('');
|
||||
|
||||
// Base64url-encode key for URL fragment
|
||||
const base64urlKey = btoa(String.fromCharCode(...new Uint8Array(rawKey)))
|
||||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
||||
|
||||
setStatus('Uploading\u2026');
|
||||
const formData = new FormData();
|
||||
formData.append('file', new Blob([payload]), file.name);
|
||||
formData.append('hash', hash);
|
||||
formData.append('name', file.name);
|
||||
|
||||
const response = await fetch('/upload', { method: 'POST', body: formData });
|
||||
if (!response.ok) throw new Error(`Server responded with ${response.status}`);
|
||||
|
||||
const { id } = await response.json();
|
||||
document.getElementById('share-link').value =
|
||||
`${window.location.origin}/download/${id}#${base64urlKey}`;
|
||||
showView('result');
|
||||
|
||||
} catch (err) {
|
||||
setStatus(`Error: ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Copy link ─────────────────────────────────────────────────────────────────
|
||||
|
||||
document.getElementById('copy-btn').addEventListener('click', async e => {
|
||||
e.stopPropagation();
|
||||
await navigator.clipboard.writeText(document.getElementById('share-link').value);
|
||||
const btn = document.getElementById('copy-btn');
|
||||
btn.textContent = 'Copied!';
|
||||
setTimeout(() => { btn.textContent = 'Copy'; }, 2000);
|
||||
});
|
||||
87
Backend/src/main/resources/templates/index.html
Normal file
87
Backend/src/main/resources/templates/index.html
Normal file
@@ -0,0 +1,87 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org" data-bs-theme="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>GTransfer</title>
|
||||
<link rel="stylesheet" th:href="@{/webjars/bootstrap/dist/css/bootstrap.min.css}">
|
||||
<link rel="stylesheet" th:href="@{/style.css}">
|
||||
<script th:src="@{/webjars/bootstrap/dist/js/bootstrap.bundle.min.js}" defer></script>
|
||||
<script th:src="@{/webjars/htmx.org/dist/htmx.min.js}" defer></script>
|
||||
<script th:src="@{/upload.js}" defer></script>
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar px-4 pt-3">
|
||||
<a class="brand fw-bold text-decoration-none fs-4" href="/">G<span>Transfer</span></a>
|
||||
<span class="badge-e2e rounded-pill fw-medium px-3 py-1">🔒 End-to-end encrypted</span>
|
||||
</nav>
|
||||
|
||||
<main class="flex-grow-1 d-flex align-items-center justify-content-center py-5 px-3">
|
||||
<div class="row align-items-center g-5" style="max-width: 960px; width: 100%;">
|
||||
<div class="col-lg-5">
|
||||
<h1 class="hero-title">Send files.<br><span>Privately.</span></h1>
|
||||
<p class="hero-subtitle mt-3">
|
||||
Share files of any size with end-to-end encryption.
|
||||
No account needed. Files are encrypted before they leave your device.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-lg-7 d-flex justify-content-center justify-content-lg-end">
|
||||
<div id="drop-zone" class="drop-zone text-center py-5 px-4 w-100">
|
||||
|
||||
<!-- State: prompt (default) -->
|
||||
<div id="view-prompt">
|
||||
<div class="drop-zone-icon mb-3">📂</div>
|
||||
<div class="mb-2">
|
||||
<strong>Choose a file</strong>
|
||||
<span class="drop-zone-text"> or drag and drop here</span>
|
||||
</div>
|
||||
<div class="drop-zone-text small">Any file type · Up to <span th:text="${maxFileSize}">10GB</span></div>
|
||||
</div>
|
||||
|
||||
<!-- State: file selected -->
|
||||
<div id="view-selected" class="d-none">
|
||||
<div class="drop-zone-icon mb-3">📄</div>
|
||||
<div class="fw-medium mb-3" id="selected-name"></div>
|
||||
<div class="d-flex gap-2 justify-content-center">
|
||||
<button id="upload-btn" class="btn btn-success px-4">Send</button>
|
||||
<button id="reset-btn" class="btn btn-link drop-zone-text text-decoration-none">Change file</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- State: uploading -->
|
||||
<div id="view-uploading" class="d-none">
|
||||
<div class="mb-3">
|
||||
<div class="spinner-border text-success" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="drop-zone-text" id="upload-status">Preparing…</div>
|
||||
</div>
|
||||
|
||||
<!-- State: result -->
|
||||
<div id="view-result" class="d-none">
|
||||
<div class="drop-zone-icon mb-3">✅</div>
|
||||
<div class="drop-zone-text mb-3">Your file is ready to share</div>
|
||||
<div class="input-group mb-2">
|
||||
<input type="text" id="share-link" class="form-control form-control-sm" readonly>
|
||||
<button id="copy-btn" class="btn btn-outline-success btn-sm">Copy</button>
|
||||
</div>
|
||||
<button id="new-upload-btn" class="btn btn-link drop-zone-text text-decoration-none small">
|
||||
Send another file
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<input type="file" id="file-input" hidden>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="text-center p-4 small">
|
||||
<a href="https://github.com/gregor-lohaus/gtransfer">Open source</a>
|
||||
· No tracking · No ads
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.gregor_lohaus.gtransfer;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class GtransferApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user