Skip to content

Commit

Permalink
Merge pull request #298 from phenobarbital/dev
Browse files Browse the repository at this point in the history
fix content-type on uploader
  • Loading branch information
phenobarbital authored Sep 27, 2024
2 parents a22064b + 265d5a2 commit b4ad2e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion navigator/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__description__ = (
"Navigator Web Framework based on aiohttp, " "with batteries included."
)
__version__ = "2.10.22"
__version__ = "2.10.23"
__author__ = "Jesus Lara"
__author_email__ = "jesuslarag@gmail.com"
__license__ = "BSD"
17 changes: 15 additions & 2 deletions navigator/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,22 @@ async def handle_upload(
if not request:
request = self.request

# Initialize a list to hold file paths if handling multiple files
# Check if Content-Type is correctly set
content_type = request.headers.get('Content-Type', '')
if 'multipart/form-data' not in content_type:
return self.response(
response={
'error': 'Invalid Content-Type. Use multipart/form-data'
},
status=406,
content_type='application/json'
)
uploaded_files = []
reader = await request.multipart()
try:
reader = await request.multipart()
except KeyError:
return {'error': 'No file uploaded'}

# Process each part of the multipart request
async for part in reader:
if part.filename:
Expand Down

0 comments on commit b4ad2e6

Please sign in to comment.