def validate_jpeg_binary(func):
""" checks the mimetype and the binary data to ensure it's a JPEG """
@wraps(func)
def wrapper(*args, **kwargs):
if request.content_type != "image/jpeg":
return ErrorResponseJson("invalid content type: {}".format(request.content_type)).make_response()
if imghdr.test_jpeg(request.data, None) != "jpeg":
return ErrorResponseJson("invalid jpeg data").make_response()
return func(*args, **kwargs)
return wrapper
评论列表
文章目录