Add Multipart Upload Functionality and Custom Middleware for PUT/PATCH Handling #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces robust support for file uploads using
multipart/form-dataand includes a custom middleware to handle PUT/PATCH requests for multipart routes. While the primary goal is to enable file upload functionality, the middleware was added to address challenges encountered with Django handling of multipart updates, even after its recent updates.Key Changes
Multipart Upload Functionality:
FileFieldandImageFieldin Django models withmultipart/form-data.FileFieldandImageFieldin models and generates routes for these fields usingmultipart/form-data.application/jsonby default.file_fields: Specify which fields in a model should usemultipart/form-data.use_multipart: Explicitly define whethercreateandupdateoperations for specific models should usemultipart/form-data.auto_multipart: Automatically enablemultipart/form-datafor models with file fields (default:True).Custom Middleware for PUT/PATCH Handling:
ProcessPutPatchMiddlewareto handlePUTandPATCHrequests asPOSTfor proper form data processing.Example Usage
Why This is Needed
Enable File Uploads:
multipart/form-dataand others useapplication/json.Custom Middleware:
PUTandPATCHrequests withmultipart/form-dataare processed correctly, enabling seamless updates for models with file fields.Next Steps
file_fields,use_multipart, andauto_multipartparameters.This PR introduces essential functionality for file uploads while addressing multipart update challenges.