When imghdr fails to deduce the image type, use file extension #807
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.
Status
Ready for review
Description of Changes
I ran into what might be an edge case, where
imghdr.what()
failed to figure out the filetype of a submitted photo. So I added in this little snippet in case imghdr fails, to determine image type using the filename.I'm not really sure what a good way to add tests for this is, since I don't really know why
imghdr
failed for this particular image. For reference, the image was https://bpdwatch.s3.amazonaws.com/8d/095b8184d1d4abd90e867a8b2d41961bcc4fbd2b42e2af6f0ad8c80ca44fc7.jpgNotes for Deployment
Screenshots (if appropriate)
Tests and linting
I have rebased my changes on current
develop
pytests pass in the development environment on my local machine
flake8
checks pass