Interruptible uploads - #231
Conversation
There was a problem hiding this comment.
Pull request overview
This PR integrates the django-resumable-async-upload package to support interruptible/resumable media uploads in the admin, focusing on Media records and bulk media uploads.
Changes:
- Add
django-resumable-async-uploadas a dependency and configure it inINSTALLED_APPS, URL routing, and project-level settings (e.g., admin resumable config). - Switch
Media.mediafilefromFileFieldtoAsyncFileFieldand update the bulk media upload form/admin logic to work with resumable uploads (usingFormResumableMultipleFileFieldandResumableAdminWidgetand saving via cleaned file path lists). - Update admin tests and supporting widgets/forms/migrations to align with the new resumable upload workflow and remove the legacy thumbnail file input widget.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| TEKDB/requirements.txt | Adds django-resumable-async-upload to the Python dependencies and keeps tooling entries consistent. |
| TEKDB/TEKDB/widgets.py | Removes the legacy ThumbnailFileInput widget now superseded by resumable upload widgets. |
| TEKDB/TEKDB/urls.py | Exposes the django_resumable_async_upload URLs under /django_resumable_async_upload/ for resumable upload endpoints. |
| TEKDB/TEKDB/tests/test_admin.py | Adjusts media bulk upload admin tests to post JSON-encoded file path lists and assert expected Media creation and thumbnail output. |
| TEKDB/TEKDB/settings.py | Registers django_resumable_async_upload in INSTALLED_APPS and configures admin resumable upload options (thumbnails, simultaneous uploads, chunk folder). |
| TEKDB/TEKDB/models.py | Changes Media.mediafile to AsyncFileField with max_files=1 while preserving existing model semantics. |
| TEKDB/TEKDB/migrations/0026_alter_media_mediafile_and_more.py | Migrates the mediafile field to AsyncFileField and bumps the recorded default for MediaBulkUpload.mediabulkname. |
| TEKDB/TEKDB/forms.py | Replaces the custom multi-file field with FormResumableMultipleFileField and ResumableAdminWidget for bulk media uploads. |
| TEKDB/TEKDB/admin.py | Updates MediaBulkUploadAdmin.save_model to consume lists of uploaded file paths, infer media type by filename, create Media instances, and maintain related event links. |
| TEKDB/Dockerfile | Documents that editable packages are installed at runtime, clarifying how dependencies like the resumable upload package are handled in containers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Django Resumable Async Upload settings | ||
| ADMIN_RESUMABLE_SHOW_THUMB = True | ||
| ADMIN_SIMULTANEOUS_UPLOADS = 1 | ||
| ADMIN_RESUMABLE_CHUNK_FOLDER = "resumable_chunks" |
There was a problem hiding this comment.
The PR description states that OrphanedFileCleanupMiddleware is used and that the Media and MediaBulkUpload admin forms use AsyncFileCleanupMixin, but I don’t see that middleware added to MIDDLEWARE or the mixin applied to the relevant admin classes; as written, resumable uploads may leave orphaned files that are never cleaned up. Please either wire up the middleware/mixins as described or update the PR description (and any related docs) to match the actual behavior in this change set.
PR against the
developbranch!Part 1 of allowing for interruptible/resumable uploads for Media in the Admin panel. Part 2 is in the django-resumable-async-upload repo.
Description
Uses the django-resumable-async-upload package to allow for uploads of media files to be interruptible. Details on how that works are in that packages repo.
The package is used in TEKDB in the following ways:
Mediarecords, uses theAsyncFileFieldmodel instead of theFileFieldMediaBulkUploadsadmin form, uses theFormResumableFileFieldto allow for resumable uploads.max_filesto be passed to theAsyncFileFieldto determine how many files can be uploaded to a file inputTo do:
AsyncFileFieldLinks