Remove file size limit
- Django upload limit raised to 10GB - SharedSpace max_file_size_mb default changed to 0 (unlimited) - Server-side and client-side checks skip when limit is 0 - Upload UI shows "No file size limit" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e89060beab
commit
8c53efe43d
|
|
@ -99,9 +99,9 @@ STORAGES = {
|
|||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = BASE_DIR / 'media'
|
||||
|
||||
# File upload limits
|
||||
FILE_UPLOAD_MAX_MEMORY_SIZE = 104857600 # 100MB
|
||||
DATA_UPLOAD_MAX_MEMORY_SIZE = 104857600 # 100MB
|
||||
# File upload limits (no limit)
|
||||
FILE_UPLOAD_MAX_MEMORY_SIZE = 10737418240 # 10GB
|
||||
DATA_UPLOAD_MAX_MEMORY_SIZE = 10737418240 # 10GB
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ class SharedSpace(models.Model):
|
|||
password_hash = models.CharField(max_length=128)
|
||||
is_active = models.BooleanField(default=True)
|
||||
max_file_size_mb = models.PositiveIntegerField(
|
||||
default=100,
|
||||
help_text="Maximum file size in MB for uploads"
|
||||
default=0,
|
||||
help_text="Maximum file size in MB for uploads (0 = unlimited)"
|
||||
)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@
|
|||
<div class="upload-zone" id="uploadZone">
|
||||
<div class="upload-icon">+</div>
|
||||
<p>Drop files here or click to select</p>
|
||||
<p class="mt-1 text-muted">Max file size: {{ space.max_file_size_mb }}MB</p>
|
||||
<p class="mt-1 text-muted">{% if space.max_file_size_mb > 0 %}Max file size: {{ space.max_file_size_mb }}MB{% else %}No file size limit{% endif %}</p>
|
||||
<input type="file" id="fileInput" multiple>
|
||||
</div>
|
||||
|
||||
|
|
@ -210,7 +210,7 @@
|
|||
const uploadZone = document.getElementById('uploadZone');
|
||||
const fileInput = document.getElementById('fileInput');
|
||||
const results = document.getElementById('results');
|
||||
const maxSize = {{ space.max_file_size_mb }} * 1024 * 1024;
|
||||
const maxSize = {{ space.max_file_size_mb }} * 1024 * 1024; // 0 = unlimited
|
||||
|
||||
// Click to select
|
||||
uploadZone.addEventListener('click', () => fileInput.click());
|
||||
|
|
@ -252,8 +252,8 @@ function formatBytes(bytes) {
|
|||
function uploadFile(file) {
|
||||
const itemId = 'upload-' + Date.now() + Math.random().toString(36).substr(2, 9);
|
||||
|
||||
// Check file size before upload
|
||||
if (file.size > maxSize) {
|
||||
// Check file size before upload (skip if unlimited)
|
||||
if (maxSize > 0 && file.size > maxSize) {
|
||||
const item = document.createElement('div');
|
||||
item.className = 'result-item error';
|
||||
item.innerHTML = `
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
<div class="upload-icon">+</div>
|
||||
<h2>Drop files here to upload</h2>
|
||||
<p>or click to select files</p>
|
||||
<p class="mt-1 text-muted">Max file size: 100MB</p>
|
||||
<p class="mt-1 text-muted">No file size limit</p>
|
||||
<input type="file" id="fileInput" multiple>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -64,11 +64,12 @@ class SharedSpaceUploadAPIView(View):
|
|||
|
||||
uploaded_file = request.FILES['file']
|
||||
|
||||
max_size_bytes = space.max_file_size_mb * 1024 * 1024
|
||||
if uploaded_file.size > max_size_bytes:
|
||||
return JsonResponse({
|
||||
'error': f'File too large. Maximum size is {space.max_file_size_mb}MB'
|
||||
}, status=400)
|
||||
if space.max_file_size_mb > 0:
|
||||
max_size_bytes = space.max_file_size_mb * 1024 * 1024
|
||||
if uploaded_file.size > max_size_bytes:
|
||||
return JsonResponse({
|
||||
'error': f'File too large. Maximum size is {space.max_file_size_mb}MB'
|
||||
}, status=400)
|
||||
|
||||
title = request.POST.get('title', '') or uploaded_file.name
|
||||
description = request.POST.get('description', '')
|
||||
|
|
|
|||
Loading…
Reference in New Issue