mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
OpenALPR Cloud API - transfer image in body of POST request (#12112)
* Send image in body of POST request * Fix tests * Implement requested change
This commit is contained in:
parent
ad24cbddcc
commit
1d2e930900
@ -109,12 +109,14 @@ class OpenAlprCloudEntity(ImageProcessingAlprEntity):
|
|||||||
websession = async_get_clientsession(self.hass)
|
websession = async_get_clientsession(self.hass)
|
||||||
params = self._params.copy()
|
params = self._params.copy()
|
||||||
|
|
||||||
params['image_bytes'] = str(b64encode(image), 'utf-8')
|
body = {
|
||||||
|
'image_bytes': str(b64encode(image), 'utf-8')
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(self.timeout, loop=self.hass.loop):
|
with async_timeout.timeout(self.timeout, loop=self.hass.loop):
|
||||||
request = yield from websession.post(
|
request = yield from websession.post(
|
||||||
OPENALPR_API_URL, params=params
|
OPENALPR_API_URL, params=params, data=body
|
||||||
)
|
)
|
||||||
|
|
||||||
data = yield from request.json()
|
data = yield from request.json()
|
||||||
|
@ -149,8 +149,7 @@ class TestOpenAlprCloud(object):
|
|||||||
'secret_key': "sk_abcxyz123456",
|
'secret_key': "sk_abcxyz123456",
|
||||||
'tasks': "plate",
|
'tasks': "plate",
|
||||||
'return_image': 0,
|
'return_image': 0,
|
||||||
'country': 'eu',
|
'country': 'eu'
|
||||||
'image_bytes': "aW1hZ2U="
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def teardown_method(self):
|
def teardown_method(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user