Use env variable for max file size limit
- Frontend: read VITE_MAX_FILE_SIZE_MB from env - Update .env.example files with limits 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -12,3 +12,7 @@ S3_ACCESS_KEY=your-access-key
|
|||||||
S3_SECRET_KEY=your-secret-key
|
S3_SECRET_KEY=your-secret-key
|
||||||
S3_BUCKET_NAME=enigfm
|
S3_BUCKET_NAME=enigfm
|
||||||
S3_REGION=ru-1
|
S3_REGION=ru-1
|
||||||
|
|
||||||
|
# Limits
|
||||||
|
MAX_FILE_SIZE_MB=10
|
||||||
|
MAX_STORAGE_GB=90
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
VITE_API_URL=http://localhost:4001
|
VITE_API_URL=http://localhost:4001
|
||||||
VITE_WS_URL=ws://localhost:4001
|
VITE_WS_URL=ws://localhost:4001
|
||||||
|
VITE_MAX_FILE_SIZE_MB=10
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<form @submit.prevent="handleUpload" class="upload-form">
|
<form @submit.prevent="handleUpload" class="upload-form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>MP3 файл (макс. 10MB)</label>
|
<label>MP3 файл (макс. {{ maxFileSizeMb }}MB)</label>
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
accept="audio/mpeg,audio/mp3"
|
accept="audio/mpeg,audio/mp3"
|
||||||
@@ -34,6 +34,9 @@ const emit = defineEmits(['uploaded'])
|
|||||||
|
|
||||||
const tracksStore = useTracksStore()
|
const tracksStore = useTracksStore()
|
||||||
|
|
||||||
|
const maxFileSizeMb = import.meta.env.VITE_MAX_FILE_SIZE_MB || 10
|
||||||
|
const maxFileSize = maxFileSizeMb * 1024 * 1024
|
||||||
|
|
||||||
const title = ref('')
|
const title = ref('')
|
||||||
const artist = ref('')
|
const artist = ref('')
|
||||||
const file = ref(null)
|
const file = ref(null)
|
||||||
@@ -45,9 +48,9 @@ function handleFileSelect(e) {
|
|||||||
const selectedFile = e.target.files[0]
|
const selectedFile = e.target.files[0]
|
||||||
if (!selectedFile) return
|
if (!selectedFile) return
|
||||||
|
|
||||||
// Check file size (10MB)
|
// Check file size
|
||||||
if (selectedFile.size > 10 * 1024 * 1024) {
|
if (selectedFile.size > maxFileSize) {
|
||||||
error.value = 'Файл слишком большой (макс. 10MB)'
|
error.value = `Файл слишком большой (макс. ${maxFileSizeMb}MB)`
|
||||||
fileInput.value.value = ''
|
fileInput.value.value = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user