Stream uploads and downloads in 1 MB blocks so memory use does not grow with file size, under both WSGI and ASGI. - S3 multipart upload API (create, upload part, list parts, complete, abort), so boto3 upload_file works for files over 8 MB. - Browser uploader on the studio page: sends 16 MB parts three at a time with retries, and resumes when the same file is picked again. Uses session-authenticated, CSRF-protected JSON endpoints under /studio/<bucket>/uploads/. - Request bodies are checked against the signed X-Amz-Content-Sha256 instead of being read into memory; signed requests must include it. boto3's aws-chunked bodies with CRC32 trailers are decoded. - Objects are written to a temporary file and renamed into place, so a failed upload leaves the existing file intact. - Downloads stream with FileResponse, or an async iterator under ASGI. - SigV4 verification uses the encoded path, fixing keys with spaces. - cleanup_uploads command removes abandoned uploads and temp files. - DATA_UPLOAD_MAX_MEMORY_SIZE is capped at 10 MB again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
2.6 KiB
Python
52 lines
2.6 KiB
Python
# Generated by Django 6.1.3 on 2026-12-01 23:59
|
|
|
|
import django.db.models.deletion
|
|
import django.utils.timezone
|
|
import uuid
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('studio', '0001_initial'),
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='MultipartUpload',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('upload_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
|
('key', models.TextField()),
|
|
('filename', models.TextField()),
|
|
('total_size', models.BigIntegerField(blank=True, null=True)),
|
|
('part_size', models.BigIntegerField(blank=True, null=True)),
|
|
('last_modified', models.BigIntegerField(blank=True, null=True)),
|
|
('overwrite', models.BooleanField(default=True)),
|
|
('status', models.CharField(choices=[('active', 'Active'), ('completed', 'Completed'), ('aborted', 'Aborted')], default='active', max_length=20)),
|
|
('etag', models.CharField(blank=True, default='', max_length=64)),
|
|
('created_at', models.DateTimeField(default=django.utils.timezone.now)),
|
|
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='multipart_uploads', to=settings.AUTH_USER_MODEL)),
|
|
('studio', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='multipart_uploads', to='studio.studio')),
|
|
],
|
|
),
|
|
migrations.CreateModel(
|
|
name='UploadPart',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('part_number', models.PositiveIntegerField()),
|
|
('size', models.BigIntegerField()),
|
|
('etag', models.CharField(max_length=32)),
|
|
('uploaded_at', models.DateTimeField(default=django.utils.timezone.now)),
|
|
('upload', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='parts', to='studio.multipartupload')),
|
|
],
|
|
options={
|
|
'ordering': ['part_number'],
|
|
'constraints': [models.UniqueConstraint(fields=('upload', 'part_number'), name='unique_part_per_upload')],
|
|
},
|
|
),
|
|
]
|