Skip to content

Commit 71eca15

Browse files
committed
Do not encode application metadata as base64 - require user to do that
1 parent 01638a0 commit 71eca15

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/vws/vws.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def update_target(
475475
width: Optional[Union[int, float]] = None,
476476
image: Optional[io.BytesIO] = None,
477477
active_flag: Optional[bool] = None,
478-
application_metadata: Optional[bytes] = None,
478+
application_metadata: Optional[str] = None,
479479
) -> None:
480480
"""
481481
Add a target to a Vuforia Web Services database.
@@ -491,8 +491,11 @@ def update_target(
491491
image: The image of the target.
492492
active_flag: Whether or not the target is active for query.
493493
application_metadata: The application metadata of the target.
494-
This will be base64 encoded. Giving ``None`` will not change
495-
the application metadata.
494+
This must be base64 encoded, for example by using::
495+
496+
base64.b64encode('input_string').decode('ascii')
497+
498+
Giving ``None`` will not change the application metadata.
496499
497500
Raises:
498501
~vws.exceptions.AuthenticationFailure: The secret key is not
@@ -528,9 +531,7 @@ def update_target(
528531
data['active_flag'] = active_flag
529532

530533
if application_metadata is not None:
531-
metadata_encoded_str = base64.b64encode(application_metadata)
532-
metadata_encoded = metadata_encoded_str.decode('ascii')
533-
data['application_metadata'] = metadata_encoded
534+
data['application_metadata'] = application_metadata
534535

535536
content = bytes(json.dumps(data), encoding='utf-8')
536537

tests/test_vws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def test_update_target(
493493
width=2,
494494
active_flag=False,
495495
image=image_file_failed_state,
496-
application_metadata=b'a',
496+
application_metadata=base64.b64encode(b'a').decode('ascii'),
497497
)
498498

499499
vws_client.wait_for_target_processed(target_id=target_id)

0 commit comments

Comments
 (0)