@@ -142,7 +142,7 @@ def add_target(
142
142
width : Union [int , float ],
143
143
image : io .BytesIO ,
144
144
active_flag : bool ,
145
- application_metadata : Optional [bytes ],
145
+ application_metadata : Optional [str ],
146
146
) -> str :
147
147
"""
148
148
Add a target to a Vuforia Web Services database.
@@ -157,7 +157,9 @@ def add_target(
157
157
image: The image of the target.
158
158
active_flag: Whether or not the target is active for query.
159
159
application_metadata: The application metadata of the target.
160
- This will be base64 encoded.
160
+ This must be base64 encoded, for example by using::
161
+
162
+ base64.b64encode('input_string').decode('ascii')
161
163
162
164
Returns:
163
165
The target ID of the new target.
@@ -185,18 +187,13 @@ def add_target(
185
187
"""
186
188
image_data = image .getvalue ()
187
189
image_data_encoded = base64 .b64encode (image_data ).decode ('ascii' )
188
- if application_metadata is None :
189
- metadata_encoded = None
190
- else :
191
- metadata_encoded_str = base64 .b64encode (application_metadata )
192
- metadata_encoded = metadata_encoded_str .decode ('ascii' )
193
190
194
191
data = {
195
192
'name' : name ,
196
193
'width' : width ,
197
194
'image' : image_data_encoded ,
198
195
'active_flag' : active_flag ,
199
- 'application_metadata' : metadata_encoded ,
196
+ 'application_metadata' : application_metadata ,
200
197
}
201
198
202
199
content = bytes (json .dumps (data ), encoding = 'utf-8' )
@@ -478,7 +475,7 @@ def update_target(
478
475
width : Optional [Union [int , float ]] = None ,
479
476
image : Optional [io .BytesIO ] = None ,
480
477
active_flag : Optional [bool ] = None ,
481
- application_metadata : Optional [bytes ] = None ,
478
+ application_metadata : Optional [str ] = None ,
482
479
) -> None :
483
480
"""
484
481
Add a target to a Vuforia Web Services database.
@@ -494,8 +491,11 @@ def update_target(
494
491
image: The image of the target.
495
492
active_flag: Whether or not the target is active for query.
496
493
application_metadata: The application metadata of the target.
497
- This will be base64 encoded. Giving ``None`` will not change
498
- 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.
499
499
500
500
Raises:
501
501
~vws.exceptions.AuthenticationFailure: The secret key is not
@@ -531,9 +531,7 @@ def update_target(
531
531
data ['active_flag' ] = active_flag
532
532
533
533
if application_metadata is not None :
534
- metadata_encoded_str = base64 .b64encode (application_metadata )
535
- metadata_encoded = metadata_encoded_str .decode ('ascii' )
536
- data ['application_metadata' ] = metadata_encoded
534
+ data ['application_metadata' ] = application_metadata
537
535
538
536
content = bytes (json .dumps (data ), encoding = 'utf-8' )
539
537
0 commit comments