static void oss_clean(const char *filename) {
    aos_pool_t *pool;
    oss_request_options_t *opts;
    aos_string_t bucket;
    aos_string_t key;
    aos_status_t *status;
    aos_table_t *resp_headers;

    aos_pool_create(&pool, NULL);

    opts = oss_request_options_create(pool);
    opts->config = oss_config_create(pool);
    aos_str_set(&opts->config->endpoint, SAMPLE_OSS_ENDPOINT);
    aos_str_set(&opts->config->access_key_id, SAMPLE_ACCESS_KEY_ID);
    aos_str_set(&opts->config->access_key_secret, SAMPLE_ACCESS_KEY_SECRET);
    opts->config->is_cname = 0; 
    opts->ctl = aos_http_controller_create(pool, 0);
    aos_str_set(&bucket, SAMPLE_BUCKET_NAME);
    aos_str_set(&key, filename);

    status = oss_delete_object(opts, &bucket, &key, &resp_headers);
    if (!aos_status_is_ok(status)) {
        aos_error_log("clean oss error. [code=%d, message=%s]", 
                      status->code, status->error_code);
        aos_error_log("example exit");
        aos_pool_destroy(pool);
        exit(-1);
    }

    aos_pool_destroy(pool);
}
void delete_object()
{
    aos_pool_t *p = NULL;
    aos_string_t bucket;
    aos_string_t object;
    int is_cname = 0;
    oss_request_options_t *options = NULL;
    aos_table_t *resp_headers = NULL;
    aos_status_t *s = NULL;

    aos_pool_create(&p, NULL);
    options = oss_request_options_create(p);
    init_sample_request_options(options, is_cname);
    aos_str_set(&bucket, BUCKET_NAME);
    aos_str_set(&object, OBJECT_NAME);

    s = oss_delete_object(options, &bucket, &object, &resp_headers);

    if (NULL != s && 204 == s->code) {
        printf("delete object succeed\n");
    } else {
        printf("delete object failed\n");
    }

    aos_pool_destroy(p);
}
Beispiel #3
0
aos_status_t *delete_test_object(const oss_request_options_t *options, 
                                 const char *bucket_name, 
                                 const char *object_name)
{
    aos_string_t bucket;
    aos_string_t object;
    aos_table_t *resp_headers;
    aos_status_t * s;

    test_object_base();
    s = oss_delete_object(options, &bucket, &object, &resp_headers);
    return s;
}
void delete_file(oss_media_file_t *file) {
    aos_pool_t *p;
    aos_string_t bucket;
    aos_string_t object;
    oss_request_options_t *options;
    aos_table_t *resp_headers;

    aos_pool_create(&p, NULL);
    options = oss_request_options_create(p);
    options->config = oss_config_create(options->pool);
    aos_str_set(&options->config->endpoint, file->endpoint);
    aos_str_set(&options->config->access_key_id, file->access_key_id);
    aos_str_set(&options->config->access_key_secret, file->access_key_secret);
    options->config->is_cname = file->is_cname;
    options->ctl = aos_http_controller_create(options->pool, 0);    
    aos_str_set(&bucket, file->bucket_name);
    aos_str_set(&object, file->object_key);

    oss_delete_object(options, &bucket, &object, &resp_headers);
}