Add resumable multipart uploads for large files
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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
af18031a14
commit
3bbb57760e
@@ -0,0 +1,28 @@
|
||||
<section class="card my-4">
|
||||
<div class="card-body">
|
||||
<h2 class="h5 card-title">Upload files</h2>
|
||||
<form method="post" data-uploader data-create-url="{% url 'studio:upload_create' studio.bucket_name %}"
|
||||
data-bucket="{{ studio.bucket_name }}" data-user-id="{{ request.user.pk }}">
|
||||
{% csrf_token %}
|
||||
<div class="row g-2 align-items-end">
|
||||
<div class="col-md-5">
|
||||
<label for="upload-files" class="form-label">Files</label>
|
||||
<input id="upload-files" class="form-control" type="file" multiple required>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<label for="upload-folder" class="form-label">Folder <span class="text-body-secondary">(optional)</span></label>
|
||||
<input id="upload-folder" class="form-control" name="folder" type="text" placeholder="videos/raw"
|
||||
autocomplete="off">
|
||||
</div>
|
||||
<div class="col-md-2 d-grid">
|
||||
{# Enabled by the uploader script, so the form can't be submitted without it. #}
|
||||
<button type="submit" class="btn btn-primary" disabled>Upload</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="form-text mb-0">
|
||||
Large files upload in parts. If an upload stops, pick the same file again to continue where it left off.
|
||||
</p>
|
||||
<ul class="list-group mt-3" data-upload-list></ul>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
@@ -4,8 +4,11 @@
|
||||
<h1>{{ studio.name }}</h1>
|
||||
<p>Bucket Name: {{ studio.bucket_name }}</p>
|
||||
<p>Group: {{ studio.group.name }}</p>
|
||||
<div id="uploaded_assets" hx-get="{% url 'studio:uploaded_assets' studio.bucket_name %}" hx-trigger="load" hx-target="#uploaded_assets" hx-swap="innerHTML">
|
||||
|
||||
<div id="uploaded_assets" hx-get="{% url 'studio:uploaded_assets' studio.bucket_name %}" hx-trigger="load, assets-changed from:body" hx-target="#uploaded_assets" hx-swap="innerHTML">
|
||||
<p>Loading uploaded assets...</p>
|
||||
</div>
|
||||
|
||||
{% include "privatestudio/_file_uploader.html" %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user