Help Center/ Object Storage Service/ C SDK Developer Guide (Ally Region)/ Getting Started (SDK for C)/ Deleting an Object (SDK for C)
Updated on 2026-01-16 GMT+08:00
Deleting an Object (SDK for C)
This example shows how to delete an object from a bucket.
Sample code:
static void test_delete_object() { obs_status ret_status = OBS_STATUS_BUTT; // Create and initialize object information. obs_object_info object_info; memset(&object_info, 0, sizeof(obs_object_info)); object_info.key = "<Your Key>"; // Create and initialize option. obs_options option; init_obs_options(&option); option.bucket_options.host_name = "<your-endpoint>"; option.bucket_options.bucket_name = "<Your bucketname>"; // Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY. // Obtain an AK/SK pair on the management console. option.bucket_options.access_key = getenv("ACCESS_KEY_ID"); option.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY"); // Set response callback function. obs_response_handler responseHandler = { &response_properties_callback, &response_complete_callback }; // Delete an object. delete_object(&option,&object_info,&responseHandler, &ret_status); if (OBS_STATUS_OK == ret_status) { printf("delete object successfully. \n"); } else { printf("delete object failed(%s).\n", obs_get_status_name(ret_status)); } }
Parent topic: Getting Started (SDK for C)
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank 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
