Skip to content
This repository was archived by the owner on Nov 8, 2021. It is now read-only.

Added face recognition API handler for bytes object to help enable DB… #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cognitive_face/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ def parse_image(image):
and return corresponding metadata.

Args:
image: A URL or a file path or a file-like object represents an image.
image: A bytes object, URL, file path or a file-like object representing an image.

Returns:
a three-item tuple consist of HTTP headers, binary data and json data
for POST.
"""
if hasattr(image, 'read'): # When image is a file-like object.
if hasattr(image, 'decode'): #When image is a bytes object
headers = {'Content-Type': 'application/octet-stream'}
data = image
return headers, data, None
elif hasattr(image, 'read'): # When image is a file-like object.
headers = {'Content-Type': 'application/octet-stream'}
data = image.read()
return headers, data, None
Expand Down