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_URL = '/media/'
|
||||||
MEDIA_ROOT = BASE_DIR / 'media'
|
MEDIA_ROOT = BASE_DIR / 'media'
|
||||||
|
|
||||||
# File upload limits
|
# File upload limits (no limit)
|
||||||
FILE_UPLOAD_MAX_MEMORY_SIZE = 104857600 # 100MB
|
FILE_UPLOAD_MAX_MEMORY_SIZE = 10737418240 # 10GB
|
||||||
DATA_UPLOAD_MAX_MEMORY_SIZE = 104857600 # 100MB
|
DATA_UPLOAD_MAX_MEMORY_SIZE = 10737418240 # 10GB
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ class SharedSpace(models.Model):
|
||||||
password_hash = models.CharField(max_length=128)
|
password_hash = models.CharField(max_length=128)
|
||||||
is_active = models.BooleanField(default=True)
|
is_active = models.BooleanField(default=True)
|
||||||
max_file_size_mb = models.PositiveIntegerField(
|
max_file_size_mb = models.PositiveIntegerField(
|
||||||
default=100,
|
default=0,
|
||||||
help_text="Maximum file size in MB for uploads"
|
help_text="Maximum file size in MB for uploads (0 = unlimited)"
|
||||||
)
|
)
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@
|
||||||
<div class="upload-zone" id="uploadZone">
|
<div class="upload-zone" id="uploadZone">
|
||||||
<div class="upload-icon">+</div>
|
<div class="upload-icon">+</div>
|
||||||
<p>Drop files here or click to select</p>
|
<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>
|
<input type="file" id="fileInput" multiple>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -210,7 +210,7 @@
|
||||||
const uploadZone = document.getElementById('uploadZone');
|
const uploadZone = document.getElementById('uploadZone');
|
||||||
const fileInput = document.getElementById('fileInput');
|
const fileInput = document.getElementById('fileInput');
|
||||||
const results = document.getElementById('results');
|
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
|
// Click to select
|
||||||
uploadZone.addEventListener('click', () => fileInput.click());
|
uploadZone.addEventListener('click', () => fileInput.click());
|
||||||
|
|
@ -252,8 +252,8 @@ function formatBytes(bytes) {
|
||||||
function uploadFile(file) {
|
function uploadFile(file) {
|
||||||
const itemId = 'upload-' + Date.now() + Math.random().toString(36).substr(2, 9);
|
const itemId = 'upload-' + Date.now() + Math.random().toString(36).substr(2, 9);
|
||||||
|
|
||||||
// Check file size before upload
|
// Check file size before upload (skip if unlimited)
|
||||||
if (file.size > maxSize) {
|
if (maxSize > 0 && file.size > maxSize) {
|
||||||
const item = document.createElement('div');
|
const item = document.createElement('div');
|
||||||
item.className = 'result-item error';
|
item.className = 'result-item error';
|
||||||
item.innerHTML = `
|
item.innerHTML = `
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
<div class="upload-icon">+</div>
|
<div class="upload-icon">+</div>
|
||||||
<h2>Drop files here to upload</h2>
|
<h2>Drop files here to upload</h2>
|
||||||
<p>or click to select files</p>
|
<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>
|
<input type="file" id="fileInput" multiple>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,11 +64,12 @@ class SharedSpaceUploadAPIView(View):
|
||||||
|
|
||||||
uploaded_file = request.FILES['file']
|
uploaded_file = request.FILES['file']
|
||||||
|
|
||||||
max_size_bytes = space.max_file_size_mb * 1024 * 1024
|
if space.max_file_size_mb > 0:
|
||||||
if uploaded_file.size > max_size_bytes:
|
max_size_bytes = space.max_file_size_mb * 1024 * 1024
|
||||||
return JsonResponse({
|
if uploaded_file.size > max_size_bytes:
|
||||||
'error': f'File too large. Maximum size is {space.max_file_size_mb}MB'
|
return JsonResponse({
|
||||||
}, status=400)
|
'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
|
title = request.POST.get('title', '') or uploaded_file.name
|
||||||
description = request.POST.get('description', '')
|
description = request.POST.get('description', '')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue