Update image upload handler to be content-type aware

Update handle_image: made filetype required and not optional
Updated handle_image usage to reflect changes
This commit is contained in:
Nathan Beals
2022-04-23 00:11:04 -04:00
parent 9adc1f7266
commit 8df3009cb2
3 changed files with 12 additions and 7 deletions

View File

@ -253,7 +253,7 @@ class Integration:
:param image_file: ByteIO stream containing the image
:param filetype: type of file to write bytes to, default to .jpeg if unknown
"""
recipe.image = File(handle_image(self.request, File(image_file, name='image'), filetype=filetype)[0], name=f'{uuid.uuid4()}_{recipe.pk}{filetype}')
recipe.image = File(handle_image(self.request, File(image_file, name='image'), filetype=filetype), name=f'{uuid.uuid4()}_{recipe.pk}{filetype}')
recipe.save()
def get_recipe_from_file(self, file):