Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.
ImageSearch
ImageSearch
- What's New
- Service Overview
- Getting Started
- API Reference
- SDK Reference
- FAQs
- General Reference
On this page
Show all
Copied.
Adding an Image
This section describes how to add an image using AK/SK authentication.
Replace the AK/SK in the sample code with the actual AK/SK. Use the setPath method of the initialized AddPictureRequestReq command to specify the URL of the image you want to add. After the configuration is complete, run the code.
- The sample code for adding an image is as follows:
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkimagesearch.v1 import * from huaweicloudsdkimagesearch.v1.region.imagesearch_region import ImageSearchRegion if __name__ == "__main__": # Set the obtained AK and SK. ak = "<YOUR AK>" sk = "<YOUR SK>" credentials = BasicCredentials(ak, sk) client = ImageSearchClient.new_builder() \ .with_credentials(credentials) \ .with_region(ImageSearchRegion.value_of("cn-north-4")) \ .build() try: request = RunAddPictureRequest() # Set the instance name. request.instance_name="instance-name" # Set the image path. request.body = AddPictureRequestReq( path="https://bucketname.obs.cn-north-4.myhuaweicloud.com/imagesearch-test.jpg" ) response = client.run_add_picture(request) print(response.status_code) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
- Execute the sample code. If the image adding result is displayed on the console, the code is successfully executed. For details, see Adding an image.
200 {"result": "Success."}
Parent topic: Using the Python SDK
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot