update ui
This commit is contained in:
1 parent
0e35933ee3
commit
29280d6490
5 files changed
+193
-440
No files matched your search
@@ -9,7 +9,7 @@ A minimal self-hosted file sharing tool. Upload a file, get a public link. Files
|
|||||||
## How it works
|
## How it works
|
||||||
|
|
||||||
1. Enter the upload password to authenticate
|
1. Enter the upload password to authenticate
|
||||||
2. Drop a file or click to browse (50 MB max)
|
2. Drop a file or click to browse (250 MB max)
|
||||||
3. Copy the public link and share it
|
3. Copy the public link and share it
|
||||||
|
|
||||||
The frontend proxies `/api/*` to the backend at `localhost:8000`, so both run separately during development.
|
The frontend proxies `/api/*` to the backend at `localhost:8000`, so both run separately during development.
|
||||||
@@ -23,6 +23,8 @@ The frontend proxies `/api/*` to the backend at `localhost:8000`, so both run se
|
|||||||
- [uv](https://docs.astral.sh/uv/) (Python package manager)
|
- [uv](https://docs.astral.sh/uv/) (Python package manager)
|
||||||
- A [Cloudflare R2](https://developers.cloudflare.com/r2/) bucket with public access enabled
|
- A [Cloudflare R2](https://developers.cloudflare.com/r2/) bucket with public access enabled
|
||||||
|
|
||||||
|
> **Upload limit:** 250 MB per file. Files are streamed directly through the backend to R2 without being loaded into memory.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Environment setup
|
## Environment setup
|
||||||
|
|||||||
+10
-12
@@ -1,13 +1,13 @@
|
|||||||
import mimetypes
|
import mimetypes
|
||||||
import secrets
|
import secrets
|
||||||
|
|
||||||
from fastapi import FastAPI, File, Form, HTTPException, UploadFile
|
from fastapi import FastAPI, File, Form, HTTPException, Request, UploadFile
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
from app.config.settings import settings
|
from app.config.settings import settings
|
||||||
from app.services.r2 import upload_file
|
from app.services.r2 import upload_file
|
||||||
|
|
||||||
MAX_FILE_SIZE = 50 * 1024 * 1024 # 50 MB
|
MAX_FILE_SIZE = 250 * 1024 * 1024 # 250 MB
|
||||||
|
|
||||||
app = FastAPI(title="File Host API")
|
app = FastAPI(title="File Host API")
|
||||||
|
|
||||||
@@ -44,23 +44,21 @@ async def auth(password: str = Form(...)):
|
|||||||
|
|
||||||
@app.post("/upload")
|
@app.post("/upload")
|
||||||
async def upload(
|
async def upload(
|
||||||
|
request: Request,
|
||||||
file: UploadFile = File(...),
|
file: UploadFile = File(...),
|
||||||
password: str = Form(...),
|
password: str = Form(...),
|
||||||
):
|
):
|
||||||
"""Validate password, enforce size limit, and upload the file to R2."""
|
"""Validate password, enforce size limit, and stream the file to R2."""
|
||||||
if password != settings.UPLOAD_PASSWORD:
|
if password != settings.UPLOAD_PASSWORD:
|
||||||
raise HTTPException(status_code=401, detail="Invalid password.")
|
raise HTTPException(status_code=401, detail="Invalid password.")
|
||||||
|
|
||||||
content = await file.read()
|
# Reject oversized requests early, before reading the body.
|
||||||
|
# Content-Length covers the whole multipart body; form overhead is negligible.
|
||||||
if not content:
|
content_length = request.headers.get("content-length")
|
||||||
raise HTTPException(status_code=400, detail="Uploaded file is empty.")
|
if content_length and int(content_length) > MAX_FILE_SIZE:
|
||||||
|
|
||||||
if len(content) > MAX_FILE_SIZE:
|
|
||||||
mb = len(content) / 1024 / 1024
|
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=413,
|
status_code=413,
|
||||||
detail=f"File is too large ({mb:.1f} MB). Maximum allowed size is 50 MB.",
|
detail="File too large. Maximum allowed size is 250 MB.",
|
||||||
)
|
)
|
||||||
|
|
||||||
content_type = (
|
content_type = (
|
||||||
@@ -70,7 +68,7 @@ async def upload(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
url = await upload_file(
|
url = await upload_file(
|
||||||
file_bytes=content,
|
file_obj=file.file,
|
||||||
object_name=object_name,
|
object_name=object_name,
|
||||||
content_type=content_type,
|
content_type=content_type,
|
||||||
)
|
)
|
||||||
|
|||||||
+11
-10
@@ -1,5 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
from typing import BinaryIO
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
from botocore.client import Config
|
from botocore.client import Config
|
||||||
@@ -21,25 +22,25 @@ def _get_r2_client():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _put_object(object_name: str, file_bytes: bytes, content_type: str) -> str:
|
def _upload_fileobj(file_obj: BinaryIO, object_name: str, content_type: str) -> str:
|
||||||
"""Blocking S3 put"""
|
"""Stream file to R2. boto3 automatically uses multipart for large files."""
|
||||||
key = f"files/{object_name}"
|
key = f"files/{object_name}"
|
||||||
|
|
||||||
_get_r2_client().put_object(
|
_get_r2_client().upload_fileobj(
|
||||||
Bucket=settings.R2_BUCKET,
|
file_obj,
|
||||||
Key=key,
|
settings.R2_BUCKET,
|
||||||
Body=file_bytes,
|
key,
|
||||||
ContentType=content_type,
|
ExtraArgs={"ContentType": content_type},
|
||||||
)
|
)
|
||||||
|
|
||||||
return f"{settings.PUBLIC_URL}/files/{object_name}"
|
return f"{settings.PUBLIC_URL}/files/{object_name}"
|
||||||
|
|
||||||
|
|
||||||
async def upload_file(file_bytes: bytes, object_name: str, content_type: str) -> str:
|
async def upload_file(file_obj: BinaryIO, object_name: str, content_type: str) -> str:
|
||||||
"""Upload a file to R2 storage"""
|
"""Upload a file to R2 storage."""
|
||||||
try:
|
try:
|
||||||
url = await asyncio.to_thread(
|
url = await asyncio.to_thread(
|
||||||
_put_object, object_name, file_bytes, content_type
|
_upload_fileobj, file_obj, object_name, content_type
|
||||||
)
|
)
|
||||||
except (BotoCoreError, ClientError) as exc:
|
except (BotoCoreError, ClientError) as exc:
|
||||||
raise RuntimeError(f"R2 upload failed: {exc}") from exc
|
raise RuntimeError(f"R2 upload failed: {exc}") from exc
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--background: #06070f;
|
--background: #313338;
|
||||||
--foreground: #f8fafc;
|
--foreground: #f2f3f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
@@ -19,8 +19,8 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
::selection {
|
::selection {
|
||||||
background: rgba(139, 92, 246, 0.35);
|
background: rgba(88, 101, 242, 0.3);
|
||||||
color: #f8fafc;
|
color: #f2f3f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
@@ -28,68 +28,14 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar-track {
|
::-webkit-scrollbar-track {
|
||||||
background: #0d0f1a;
|
background: #2b2d31;
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
::-webkit-scrollbar-thumb {
|
||||||
background: rgba(255, 255, 255, 0.08);
|
background: rgba(255, 255, 255, 0.1);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb:hover {
|
::-webkit-scrollbar-thumb:hover {
|
||||||
background: rgba(255, 255, 255, 0.14);
|
background: rgba(255, 255, 255, 0.18);
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes shimmer {
|
|
||||||
0% {
|
|
||||||
background-position: -200% center;
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
background-position: 200% center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes pulse-soft {
|
|
||||||
0%,
|
|
||||||
100% {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
50% {
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes float-orb {
|
|
||||||
0%,
|
|
||||||
100% {
|
|
||||||
transform: translateY(0px) scale(1);
|
|
||||||
}
|
|
||||||
50% {
|
|
||||||
transform: translateY(-20px) scale(1.04);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-bar {
|
|
||||||
background: linear-gradient(
|
|
||||||
90deg,
|
|
||||||
#7c3aed,
|
|
||||||
#3b82f6,
|
|
||||||
#06b6d4,
|
|
||||||
#3b82f6,
|
|
||||||
#7c3aed
|
|
||||||
);
|
|
||||||
background-size: 300% auto;
|
|
||||||
animation: shimmer 2.5s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.orb-1 {
|
|
||||||
animation: float-orb 12s ease-in-out infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.orb-2 {
|
|
||||||
animation: float-orb 16s ease-in-out infinite reverse;
|
|
||||||
}
|
|
||||||
|
|
||||||
.orb-3 {
|
|
||||||
animation: float-orb 10s ease-in-out infinite 4s;
|
|
||||||
}
|
}
|
||||||
+162
-356
@@ -3,13 +3,11 @@
|
|||||||
import {
|
import {
|
||||||
AlertCircle,
|
AlertCircle,
|
||||||
CheckCircle2,
|
CheckCircle2,
|
||||||
CloudUpload,
|
|
||||||
Copy,
|
Copy,
|
||||||
ExternalLink,
|
ExternalLink,
|
||||||
Lock,
|
Lock,
|
||||||
LockOpen,
|
RotateCcw,
|
||||||
RefreshCw,
|
Upload,
|
||||||
UploadCloud,
|
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { ChangeEvent, DragEvent, useCallback, useRef, useState } from "react";
|
import { ChangeEvent, DragEvent, useCallback, useRef, useState } from "react";
|
||||||
|
|
||||||
@@ -134,7 +132,7 @@ export default function Home() {
|
|||||||
[uploadFile],
|
[uploadFile],
|
||||||
);
|
);
|
||||||
|
|
||||||
// ── Copy URL ──────────────────────────────────────────────────────────────
|
// ── Copy ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const handleCopy = async () => {
|
const handleCopy = async () => {
|
||||||
await navigator.clipboard.writeText(resultUrl);
|
await navigator.clipboard.writeText(resultUrl);
|
||||||
@@ -151,119 +149,38 @@ export default function Home() {
|
|||||||
// ── Render ────────────────────────────────────────────────────────────────
|
// ── Render ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="min-h-screen flex items-center justify-center p-6 relative overflow-hidden bg-[#06070f]">
|
<main
|
||||||
{/* ── Ambient background orbs ──────────────────────────────────── */}
|
className="min-h-screen bg-[#313338] flex flex-col items-center justify-center px-4 py-12"
|
||||||
<div className="pointer-events-none fixed inset-0 overflow-hidden">
|
|
||||||
<div
|
|
||||||
className="orb-1 absolute -top-56 -left-56 w-[600px] h-[600px] rounded-full"
|
|
||||||
style={{
|
style={{
|
||||||
background:
|
paddingTop: "max(3rem, env(safe-area-inset-top))",
|
||||||
"radial-gradient(circle, rgba(109,40,217,0.18) 0%, transparent 70%)",
|
paddingBottom: "max(3rem, env(safe-area-inset-bottom))",
|
||||||
filter: "blur(40px)",
|
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
<div
|
<div className="w-full max-w-sm">
|
||||||
className="orb-2 absolute -bottom-56 -right-56 w-[600px] h-[600px] rounded-full"
|
{/* ── Header ─────────────────────────────────────────────────────── */}
|
||||||
style={{
|
<div className="flex flex-col items-center text-center mb-8 gap-3">
|
||||||
background:
|
<div className="w-12 h-12 rounded-[14px] bg-[#2b2d31] border border-white/[0.06] flex items-center justify-center">
|
||||||
"radial-gradient(circle, rgba(37,99,235,0.18) 0%, transparent 70%)",
|
<Upload className="w-5 h-5 text-[#f2f3f5]" strokeWidth={1.75} />
|
||||||
filter: "blur(40px)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
className="orb-3 absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] h-[400px] rounded-full"
|
|
||||||
style={{
|
|
||||||
background:
|
|
||||||
"radial-gradient(circle, rgba(79,70,229,0.1) 0%, transparent 70%)",
|
|
||||||
filter: "blur(60px)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
{/* ── Subtle dot grid ──────────────────────────────────────────── */}
|
<h1 className="text-[22px] font-semibold text-[#f2f3f5] tracking-tight leading-snug">
|
||||||
<div
|
|
||||||
className="pointer-events-none fixed inset-0"
|
|
||||||
style={{
|
|
||||||
backgroundImage:
|
|
||||||
"radial-gradient(rgba(255,255,255,0.06) 1px, transparent 1px)",
|
|
||||||
backgroundSize: "28px 28px",
|
|
||||||
maskImage:
|
|
||||||
"radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%)",
|
|
||||||
WebkitMaskImage:
|
|
||||||
"radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* ── Card ─────────────────────────────────────────────────────── */}
|
|
||||||
<div className="w-full max-w-md relative z-10">
|
|
||||||
<div
|
|
||||||
className="rounded-2xl overflow-hidden"
|
|
||||||
style={{
|
|
||||||
background: "rgba(255,255,255,0.032)",
|
|
||||||
backdropFilter: "blur(28px)",
|
|
||||||
WebkitBackdropFilter: "blur(28px)",
|
|
||||||
border: "1px solid rgba(255,255,255,0.07)",
|
|
||||||
boxShadow:
|
|
||||||
"0 0 0 1px rgba(255,255,255,0.03) inset, 0 32px 64px -16px rgba(0,0,0,0.7), 0 8px 32px rgba(109,40,217,0.08)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{/* Gradient top-bar accent */}
|
|
||||||
<div
|
|
||||||
className="h-[2px] w-full"
|
|
||||||
style={{
|
|
||||||
background: "linear-gradient(90deg, #7c3aed, #3b82f6, #06b6d4)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="p-8 flex flex-col gap-6">
|
|
||||||
{/* ── Header ─────────────────────────────────────────────── */}
|
|
||||||
<div className="flex flex-col items-center gap-3 pt-1">
|
|
||||||
<div
|
|
||||||
className="w-16 h-16 rounded-2xl flex items-center justify-center"
|
|
||||||
style={{
|
|
||||||
background:
|
|
||||||
"linear-gradient(135deg, rgba(124,58,237,0.22), rgba(59,130,246,0.22))",
|
|
||||||
border: "1px solid rgba(124,58,237,0.28)",
|
|
||||||
boxShadow: "0 8px 24px rgba(124,58,237,0.18)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CloudUpload
|
|
||||||
className="w-8 h-8 text-violet-300"
|
|
||||||
strokeWidth={1.5}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="text-center">
|
|
||||||
<h1
|
|
||||||
className="text-[1.6rem] font-bold tracking-tight leading-tight"
|
|
||||||
style={{
|
|
||||||
background:
|
|
||||||
"linear-gradient(135deg, #c4b5fd 0%, #93c5fd 100%)",
|
|
||||||
WebkitBackgroundClip: "text",
|
|
||||||
WebkitTextFillColor: "transparent",
|
|
||||||
backgroundClip: "text",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
File Host
|
File Host
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-xs text-slate-600 mt-1 tracking-wide">
|
<p className="text-[13px] text-[#b5bac1] mt-0.5">
|
||||||
50 MB max · expires in 24 h
|
250 MB max · expires in 24 h
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Divider */}
|
{/* ── Card ───────────────────────────────────────────────────────── */}
|
||||||
<div
|
<div className="bg-[#2b2d31] rounded-2xl border border-white/[0.06] overflow-hidden">
|
||||||
className="h-px"
|
{/* Auth row */}
|
||||||
style={{
|
<div className="px-5 pt-5 pb-5 border-b border-white/[0.06]">
|
||||||
background:
|
|
||||||
"linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* ── Auth ───────────────────────────────────────────────── */}
|
|
||||||
{isLocked ? (
|
{isLocked ? (
|
||||||
<div className="flex gap-2">
|
<div className="flex flex-col gap-3">
|
||||||
|
<label className="text-[13px] font-medium text-[#f2f3f5]">
|
||||||
|
Password
|
||||||
|
</label>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
value={password}
|
value={password}
|
||||||
@@ -272,236 +189,73 @@ export default function Home() {
|
|||||||
setPasswordError(false);
|
setPasswordError(false);
|
||||||
}}
|
}}
|
||||||
onKeyDown={(e) => e.key === "Enter" && handleUnlock()}
|
onKeyDown={(e) => e.key === "Enter" && handleUnlock()}
|
||||||
placeholder="Enter password…"
|
placeholder="Enter password"
|
||||||
className="flex-1 rounded-xl px-4 py-2.5 text-sm text-white placeholder-slate-600 outline-none transition-all duration-200"
|
className={[
|
||||||
style={{
|
"w-full h-11 px-3.5 rounded-xl text-[15px] text-[#f2f3f5]",
|
||||||
background: "rgba(255,255,255,0.04)",
|
"bg-[#1e1f22] placeholder:text-[#4e5058] outline-none",
|
||||||
border: passwordError
|
"border transition-all duration-150",
|
||||||
? "1px solid rgba(239,68,68,0.6)"
|
passwordError
|
||||||
: "1px solid rgba(255,255,255,0.08)",
|
? "border-[#ed4245] ring-2 ring-[#ed4245]/15"
|
||||||
boxShadow: passwordError
|
: "border-transparent focus:border-[#5865f2]/50 focus:ring-2 focus:ring-[#5865f2]/15",
|
||||||
? "0 0 0 3px rgba(239,68,68,0.1)"
|
].join(" ")}
|
||||||
: undefined,
|
|
||||||
}}
|
|
||||||
onFocus={(e) => {
|
|
||||||
if (!passwordError)
|
|
||||||
(e.target as HTMLInputElement).style.border =
|
|
||||||
"1px solid rgba(124,58,237,0.5)";
|
|
||||||
(e.target as HTMLInputElement).style.boxShadow =
|
|
||||||
"0 0 0 3px rgba(124,58,237,0.12)";
|
|
||||||
}}
|
|
||||||
onBlur={(e) => {
|
|
||||||
if (!passwordError) {
|
|
||||||
(e.target as HTMLInputElement).style.border =
|
|
||||||
"1px solid rgba(255,255,255,0.08)";
|
|
||||||
(e.target as HTMLInputElement).style.boxShadow = "none";
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
{passwordError && (
|
||||||
|
<p className="text-[12px] text-[#ed4245] -mt-1">
|
||||||
|
Incorrect password.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
<button
|
<button
|
||||||
onClick={handleUnlock}
|
onClick={handleUnlock}
|
||||||
className="flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold text-white shrink-0 transition-all duration-150 hover:brightness-110 active:scale-[0.96]"
|
className="w-full h-11 rounded-xl bg-[#5865f2] text-white text-[15px] font-medium tracking-tight transition-opacity active:opacity-75 select-none"
|
||||||
style={{
|
|
||||||
background: "linear-gradient(135deg, #7c3aed, #2563eb)",
|
|
||||||
boxShadow: "0 4px 18px rgba(124,58,237,0.35)",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Lock className="w-3.5 h-3.5" />
|
|
||||||
Unlock
|
Unlock
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div
|
<div className="flex items-center gap-2.5 py-0.5">
|
||||||
className="flex items-center gap-2.5 px-4 py-2.5 rounded-xl text-sm"
|
<div className="w-2 h-2 rounded-full bg-[#23a55a] shrink-0" />
|
||||||
style={{
|
<span className="text-[14px] font-medium text-[#f2f3f5]">
|
||||||
background: "rgba(52,211,153,0.08)",
|
Unlocked
|
||||||
border: "1px solid rgba(52,211,153,0.18)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<LockOpen className="w-4 h-4 text-emerald-400" />
|
|
||||||
<span className="font-medium text-emerald-400">
|
|
||||||
Authenticated
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* ── Upload zone ────────────────────────────────────────── */}
|
{/* Upload / progress / result */}
|
||||||
<div
|
<div className="px-5 py-5 flex flex-col gap-4">
|
||||||
onDragOver={handleDragOver}
|
|
||||||
onDragLeave={handleDragLeave}
|
|
||||||
onDrop={handleDrop}
|
|
||||||
onClick={() => isInteractable && fileInputRef.current?.click()}
|
|
||||||
className="relative rounded-xl border-2 border-dashed flex flex-col items-center justify-center gap-4 p-10 text-center transition-all duration-200"
|
|
||||||
style={{
|
|
||||||
minHeight: "190px",
|
|
||||||
borderColor: isUploading
|
|
||||||
? "rgba(124,58,237,0.45)"
|
|
||||||
: isLocked
|
|
||||||
? "rgba(255,255,255,0.05)"
|
|
||||||
: isDragging
|
|
||||||
? "rgba(124,58,237,0.65)"
|
|
||||||
: "rgba(255,255,255,0.09)",
|
|
||||||
background: isDragging
|
|
||||||
? "rgba(124,58,237,0.07)"
|
|
||||||
: isUploading
|
|
||||||
? "rgba(124,58,237,0.04)"
|
|
||||||
: "rgba(255,255,255,0.015)",
|
|
||||||
cursor: isUploading
|
|
||||||
? "default"
|
|
||||||
: isLocked
|
|
||||||
? "not-allowed"
|
|
||||||
: isDragging
|
|
||||||
? "copy"
|
|
||||||
: "pointer",
|
|
||||||
opacity: isLocked ? 0.45 : 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
ref={fileInputRef}
|
|
||||||
type="file"
|
|
||||||
className="hidden"
|
|
||||||
onChange={handleFileChange}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{isUploading ? (
|
{isUploading ? (
|
||||||
/* Uploading state */
|
/* ── Uploading ─────────────────────────────────────────────── */
|
||||||
<>
|
<div className="flex flex-col gap-3 py-1">
|
||||||
<div
|
<div className="flex items-center gap-3">
|
||||||
className="w-14 h-14 rounded-2xl flex items-center justify-center"
|
<div className="w-9 h-9 rounded-[10px] bg-[#1e1f22] flex items-center justify-center shrink-0">
|
||||||
style={{
|
<Upload
|
||||||
background:
|
className="w-4 h-4 text-[#b5bac1]"
|
||||||
"linear-gradient(135deg, rgba(124,58,237,0.2), rgba(59,130,246,0.2))",
|
strokeWidth={1.75}
|
||||||
border: "1px solid rgba(124,58,237,0.3)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<UploadCloud
|
|
||||||
className="w-7 h-7 text-violet-300"
|
|
||||||
style={{
|
|
||||||
animation: "pulse-soft 1.8s ease-in-out infinite",
|
|
||||||
}}
|
|
||||||
strokeWidth={1.5}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full flex flex-col gap-2.5">
|
<p className="text-[14px] text-[#f2f3f5] font-medium truncate flex-1 min-w-0">
|
||||||
<p className="text-sm text-slate-300 font-medium truncate max-w-[220px] mx-auto">
|
|
||||||
{pendingFileName}
|
{pendingFileName}
|
||||||
</p>
|
</p>
|
||||||
|
<span className="text-[13px] text-[#b5bac1] tabular-nums shrink-0 ml-2">
|
||||||
|
{progress}%
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="h-[3px] w-full rounded-full bg-[#1e1f22] overflow-hidden">
|
||||||
<div
|
<div
|
||||||
className="relative w-full rounded-full overflow-hidden"
|
className="h-full rounded-full bg-[#5865f2] transition-all duration-300 ease-out"
|
||||||
style={{
|
|
||||||
height: "5px",
|
|
||||||
background: "rgba(255,255,255,0.06)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="absolute inset-y-0 left-0 rounded-full progress-bar transition-[width] duration-300 ease-out"
|
|
||||||
style={{ width: `${progress}%` }}
|
style={{ width: `${progress}%` }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-slate-500 tabular-nums">
|
|
||||||
{progress}%
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
) : status === "done" && resultUrl ? (
|
||||||
) : isDragging ? (
|
/* ── Done ─────────────────────────────────────────────────── */
|
||||||
/* Drag-over state */
|
<div className="flex flex-col gap-3">
|
||||||
<>
|
<div className="flex items-center gap-2">
|
||||||
<div
|
<CheckCircle2
|
||||||
className="w-14 h-14 rounded-2xl flex items-center justify-center"
|
className="w-4 h-4 text-[#23a55a] shrink-0"
|
||||||
style={{
|
strokeWidth={2}
|
||||||
background:
|
|
||||||
"linear-gradient(135deg, rgba(124,58,237,0.3), rgba(59,130,246,0.3))",
|
|
||||||
border: "1px solid rgba(124,58,237,0.5)",
|
|
||||||
boxShadow: "0 0 24px rgba(124,58,237,0.2)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<UploadCloud
|
|
||||||
className="w-7 h-7 text-violet-200"
|
|
||||||
strokeWidth={1.5}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
<span className="text-[14px] font-medium text-[#f2f3f5]">
|
||||||
<p className="text-sm font-semibold text-violet-300">
|
|
||||||
Drop to upload
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
/* Idle state */
|
|
||||||
<>
|
|
||||||
<div
|
|
||||||
className="w-14 h-14 rounded-2xl flex items-center justify-center transition-all duration-200"
|
|
||||||
style={
|
|
||||||
isLocked
|
|
||||||
? {
|
|
||||||
background: "rgba(255,255,255,0.04)",
|
|
||||||
border: "1px solid rgba(255,255,255,0.06)",
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
background:
|
|
||||||
"linear-gradient(135deg, rgba(124,58,237,0.14), rgba(59,130,246,0.14))",
|
|
||||||
border: "1px solid rgba(124,58,237,0.22)",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<UploadCloud
|
|
||||||
className={
|
|
||||||
isLocked
|
|
||||||
? "w-7 h-7 text-slate-700"
|
|
||||||
: "w-7 h-7 text-slate-400"
|
|
||||||
}
|
|
||||||
strokeWidth={1.5}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-col gap-1.5">
|
|
||||||
<p
|
|
||||||
className={`text-sm font-medium ${isLocked ? "text-slate-700" : "text-slate-300"}`}
|
|
||||||
>
|
|
||||||
{isLocked
|
|
||||||
? "Enter password to unlock"
|
|
||||||
: "Drop a file here or click to browse"}
|
|
||||||
</p>
|
|
||||||
{!isLocked && (
|
|
||||||
<p className="text-xs text-slate-600">
|
|
||||||
Any file type · up to 50 MB
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* ── Error ──────────────────────────────────────────────── */}
|
|
||||||
{errorMessage && (
|
|
||||||
<div
|
|
||||||
className="rounded-xl flex items-start gap-3 px-4 py-3.5"
|
|
||||||
style={{
|
|
||||||
background: "rgba(239,68,68,0.07)",
|
|
||||||
border: "1px solid rgba(239,68,68,0.2)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<AlertCircle className="w-4 h-4 text-red-400 mt-0.5 shrink-0" />
|
|
||||||
<p className="text-sm text-red-400 break-all leading-relaxed">
|
|
||||||
{errorMessage}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ── Success ────────────────────────────────────────────── */}
|
|
||||||
{status === "done" && resultUrl && (
|
|
||||||
<div
|
|
||||||
className="rounded-xl flex flex-col gap-4 p-4"
|
|
||||||
style={{
|
|
||||||
background: "rgba(52,211,153,0.06)",
|
|
||||||
border: "1px solid rgba(52,211,153,0.15)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2.5">
|
|
||||||
<div
|
|
||||||
className="w-5 h-5 rounded-full flex items-center justify-center shrink-0"
|
|
||||||
style={{ background: "rgba(52,211,153,0.15)" }}
|
|
||||||
>
|
|
||||||
<CheckCircle2 className="w-3.5 h-3.5 text-emerald-400" />
|
|
||||||
</div>
|
|
||||||
<span className="text-sm font-semibold text-emerald-400">
|
|
||||||
Upload complete
|
Upload complete
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -510,56 +264,32 @@ export default function Home() {
|
|||||||
readOnly
|
readOnly
|
||||||
value={resultUrl}
|
value={resultUrl}
|
||||||
onClick={(e) => (e.target as HTMLInputElement).select()}
|
onClick={(e) => (e.target as HTMLInputElement).select()}
|
||||||
className="w-full rounded-xl px-3.5 py-2.5 text-sm text-slate-300 outline-none cursor-text font-mono transition-all duration-200"
|
className="w-full h-10 px-3 rounded-xl bg-[#1e1f22] border border-transparent focus:border-white/[0.12] text-[12px] text-[#f2f3f5] font-mono outline-none cursor-text transition-colors"
|
||||||
style={{
|
|
||||||
background: "rgba(255,255,255,0.04)",
|
|
||||||
border: "1px solid rgba(255,255,255,0.08)",
|
|
||||||
}}
|
|
||||||
onFocus={(e) => {
|
|
||||||
(e.target as HTMLInputElement).style.border =
|
|
||||||
"1px solid rgba(255,255,255,0.14)";
|
|
||||||
}}
|
|
||||||
onBlur={(e) => {
|
|
||||||
(e.target as HTMLInputElement).style.border =
|
|
||||||
"1px solid rgba(255,255,255,0.08)";
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<button
|
<button
|
||||||
onClick={handleCopy}
|
onClick={handleCopy}
|
||||||
className="flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 active:scale-[0.97]"
|
className={[
|
||||||
style={
|
"flex-1 h-11 rounded-xl text-[14px] font-medium",
|
||||||
|
"flex items-center justify-center gap-1.5",
|
||||||
|
"transition-all active:opacity-70 select-none",
|
||||||
copied
|
copied
|
||||||
? {
|
? "bg-[#23a55a]/10 text-[#23a55a]"
|
||||||
background: "rgba(52,211,153,0.12)",
|
: "bg-[#1e1f22] text-[#f2f3f5]",
|
||||||
border: "1px solid rgba(52,211,153,0.25)",
|
].join(" ")}
|
||||||
color: "#6ee7b7",
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
background: "rgba(255,255,255,0.05)",
|
|
||||||
border: "1px solid rgba(255,255,255,0.09)",
|
|
||||||
color: "#cbd5e1",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Copy className="w-3.5 h-3.5" />
|
<Copy className="w-3.5 h-3.5" strokeWidth={2} />
|
||||||
{copied ? "Copied!" : "Copy URL"}
|
{copied ? "Copied" : "Copy"}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href={resultUrl}
|
href={resultUrl}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 hover:brightness-110 active:scale-[0.97]"
|
className="flex-1 h-11 rounded-xl bg-[#5865f2] text-white text-[14px] font-medium flex items-center justify-center gap-1.5 transition-opacity active:opacity-80 select-none"
|
||||||
style={{
|
|
||||||
background:
|
|
||||||
"linear-gradient(135deg, rgba(124,58,237,0.18), rgba(59,130,246,0.18))",
|
|
||||||
border: "1px solid rgba(124,58,237,0.25)",
|
|
||||||
color: "#c4b5fd",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<ExternalLink className="w-3.5 h-3.5" />
|
<ExternalLink className="w-3.5 h-3.5" strokeWidth={2} />
|
||||||
Open
|
Open
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -570,18 +300,94 @@ export default function Home() {
|
|||||||
setErrorMessage("");
|
setErrorMessage("");
|
||||||
setStatus("unlocked");
|
setStatus("unlocked");
|
||||||
}}
|
}}
|
||||||
className="flex items-center justify-center gap-1.5 text-xs text-slate-600 hover:text-slate-400 transition-colors duration-150"
|
className="flex items-center justify-center gap-1.5 text-[13px] text-[#80848e] transition-colors active:text-[#f2f3f5] select-none"
|
||||||
>
|
>
|
||||||
<RefreshCw className="w-3 h-3" />
|
<RotateCcw className="w-3 h-3" strokeWidth={2} />
|
||||||
Upload another file
|
Upload another
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
/* ── Drop zone ─────────────────────────────────────────────── */
|
||||||
|
<div
|
||||||
|
onDragOver={handleDragOver}
|
||||||
|
onDragLeave={handleDragLeave}
|
||||||
|
onDrop={handleDrop}
|
||||||
|
onClick={() => isInteractable && fileInputRef.current?.click()}
|
||||||
|
className={[
|
||||||
|
"rounded-xl border-2 border-dashed",
|
||||||
|
"flex flex-col items-center justify-center gap-2.5",
|
||||||
|
"py-10 px-4 text-center",
|
||||||
|
"transition-all duration-150 select-none",
|
||||||
|
isLocked
|
||||||
|
? "border-white/[0.06] cursor-not-allowed opacity-40"
|
||||||
|
: isDragging
|
||||||
|
? "border-[#5865f2]/40 bg-[#5865f2]/[0.04] cursor-copy"
|
||||||
|
: "border-white/[0.08] cursor-pointer hover:border-white/[0.14] hover:bg-white/[0.02] active:bg-white/[0.03]",
|
||||||
|
].join(" ")}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
ref={fileInputRef}
|
||||||
|
type="file"
|
||||||
|
className="hidden"
|
||||||
|
onChange={handleFileChange}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className={[
|
||||||
|
"w-10 h-10 rounded-[12px] flex items-center justify-center transition-colors",
|
||||||
|
isDragging ? "bg-[#5865f2]/10" : "bg-[#1e1f22]",
|
||||||
|
].join(" ")}
|
||||||
|
>
|
||||||
|
<Upload
|
||||||
|
className={[
|
||||||
|
"w-4.5 h-4.5 transition-colors",
|
||||||
|
isDragging ? "text-[#5865f2]" : "text-[#80848e]",
|
||||||
|
].join(" ")}
|
||||||
|
strokeWidth={1.75}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p
|
||||||
|
className={[
|
||||||
|
"text-[14px] font-medium transition-colors",
|
||||||
|
isDragging
|
||||||
|
? "text-[#5865f2]"
|
||||||
|
: isLocked
|
||||||
|
? "text-[#80848e]"
|
||||||
|
: "text-[#f2f3f5]",
|
||||||
|
].join(" ")}
|
||||||
|
>
|
||||||
|
{isLocked
|
||||||
|
? "Enter password to unlock"
|
||||||
|
: isDragging
|
||||||
|
? "Drop to upload"
|
||||||
|
: "Drop file or tap to browse"}
|
||||||
|
</p>
|
||||||
|
{!isLocked && (
|
||||||
|
<p className="text-[12px] text-[#80848e] mt-1">
|
||||||
|
Any file type · up to 250 MB
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* ── Error ────────────────────────────────────────────────── */}
|
||||||
|
{errorMessage && (
|
||||||
|
<div className="flex items-start gap-2.5 px-3.5 py-3 rounded-xl bg-[#ed4245]/[0.08] border border-[#ed4245]/[0.15]">
|
||||||
|
<AlertCircle
|
||||||
|
className="w-4 h-4 text-[#ed4245] shrink-0 mt-px"
|
||||||
|
strokeWidth={2}
|
||||||
|
/>
|
||||||
|
<p className="text-[13px] text-[#ed4245] break-all leading-relaxed">
|
||||||
|
{errorMessage}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Footer */}
|
{/* ── Footer ─────────────────────────────────────────────────────── */}
|
||||||
<p className="text-center text-[11px] text-slate-700 mt-5 tracking-wide">
|
<p className="text-center text-[12px] text-[#80848e] mt-6">
|
||||||
Files are automatically deleted after 24 hours
|
Files are automatically deleted after 24 hours
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user