@@ -142,7 +142,7 @@ def add_target(
142142 width : Union [int , float ],
143143 image : io .BytesIO ,
144144 active_flag : bool ,
145- application_metadata : Optional [bytes ],
145+ application_metadata : Optional [str ],
146146 ) -> str :
147147 """
148148 Add a target to a Vuforia Web Services database.
@@ -157,7 +157,9 @@ def add_target(
157157 image: The image of the target.
158158 active_flag: Whether or not the target is active for query.
159159 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')
161163
162164 Returns:
163165 The target ID of the new target.
@@ -185,18 +187,13 @@ def add_target(
185187 """
186188 image_data = image .getvalue ()
187189 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' )
193190
194191 data = {
195192 'name' : name ,
196193 'width' : width ,
197194 'image' : image_data_encoded ,
198195 'active_flag' : active_flag ,
199- 'application_metadata' : metadata_encoded ,
196+ 'application_metadata' : application_metadata ,
200197 }
201198
202199 content = bytes (json .dumps (data ), encoding = 'utf-8' )
@@ -478,7 +475,7 @@ def update_target(
478475 width : Optional [Union [int , float ]] = None ,
479476 image : Optional [io .BytesIO ] = None ,
480477 active_flag : Optional [bool ] = None ,
481- application_metadata : Optional [bytes ] = None ,
478+ application_metadata : Optional [str ] = None ,
482479 ) -> None :
483480 """
484481 Add a target to a Vuforia Web Services database.
@@ -494,8 +491,11 @@ def update_target(
494491 image: The image of the target.
495492 active_flag: Whether or not the target is active for query.
496493 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.
499499
500500 Raises:
501501 ~vws.exceptions.AuthenticationFailure: The secret key is not
@@ -531,9 +531,7 @@ def update_target(
531531 data ['active_flag' ] = active_flag
532532
533533 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
537535
538536 content = bytes (json .dumps (data ), encoding = 'utf-8' )
539537
0 commit comments