URL for Deleting an Object
If you have any questions during development, post them on the Issues page of GitHub.
static void test_delete_object_auth() { obs_status ret_status = OBS_STATUS_BUTT; // 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. For details, see https://support.huaweicloud.com/en-us/usermanual-ca/ca_01_0003.html. option.bucket_options.access_key = getenv("ACCESS_KEY_ID"); option.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY"); temp_auth_configure tempauth; tempAuthResult ptrResult; memset_s(&ptrResult,sizeof(tempAuthResult),0,sizeof(tempAuthResult)); // Callback data tempauth.callback_data = (void *)(&ptrResult); // Validity period tempauth.expires = 10; // Callback function returns and generates the temporary URL. tempauth.temp_auth_callback = &tempAuthCallBack_getResult; option.temp_auth = &tempauth; // Object information obs_object_info object_info; memset(&object_info,0,sizeof(obs_object_info)); object_info.key = key; // Assign a value to the callback function. obs_response_handler resqonseHandler = { &response_properties_callback, &response_complete_callback }; // Delete an object. delete_object(&option,&object_info,&resqonseHandler, &ret_status); if (OBS_STATUS_OK == ret_status) {printf("the temporary signature url of delete object generated successfully. The result is recorded in the tmpAuthUrl.txt file. \n"); } else { printf("the temporary signature url of delete object generation failed(%s).\n", obs_get_status_name(ret_status)); } }
Last Article: URL for Listing Objects
Next Article: Versioning Management
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.