Skip to content

Commit 3bbe8da

Browse files
committed
configurable 1GB max file size on frontend + worker
1 parent 5473878 commit 3bbe8da

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/App.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DropZone } from './components/DropZone'
33
import { Player } from './components/Player'
44
import { UploadProgress } from './components/UploadProgress'
55
import { uploadVideo, deleteVideo } from './api'
6+
import { MAX_FILE_SIZE } from './config'
67
import './App.css'
78

89
type AppState =
@@ -35,6 +36,12 @@ export default function App() {
3536
videoIdRef.current = null
3637
}
3738

39+
if (file.size > MAX_FILE_SIZE) {
40+
const maxMB = Math.round(MAX_FILE_SIZE / (1024 * 1024))
41+
setState({ phase: 'error', message: `File too large (max ${maxMB}MB)` })
42+
return
43+
}
44+
3845
setState({ phase: 'uploading', file, progress: 0 })
3946

4047
try {

src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** Maximum file size in bytes (1GB) */
2+
export const MAX_FILE_SIZE = 1 * 1024 * 1024 * 1024

tsconfig.app.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"root":["./src/app.tsx","./src/api.ts","./src/main.tsx","./src/vite-env.d.ts","./src/components/castbutton.tsx","./src/components/dropzone.tsx","./src/components/player.tsx","./src/components/uploadprogress.tsx"],"version":"5.9.3"}
1+
{"root":["./src/app.tsx","./src/api.ts","./src/config.ts","./src/main.tsx","./src/vite-env.d.ts","./src/components/castbutton.tsx","./src/components/dropzone.tsx","./src/components/player.tsx","./src/components/uploadprogress.tsx"],"version":"5.9.3"}

worker/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ interface Env {
22
BUCKET: R2Bucket
33
}
44

5-
const MAX_FILE_SIZE = 500 * 1024 * 1024 // 500MB
5+
const MAX_FILE_SIZE = 1 * 1024 * 1024 * 1024 // 1GB
66
const MAX_AGE_MS = 60 * 60 * 1000 // 1 hour
77
const CORS_HEADERS = {
88
'Access-Control-Allow-Origin': '*',

0 commit comments

Comments
 (0)