暂无个人介绍
const char BUCKET_NAME[] = "xxxxxx";
const char OSS_SYMLINK_TAEGET[] = "x-oss-symlink-target";
const char OSS_REQ_PARAM_SYMLINK[] = "symlink";
aos_status_t *oss_put_symlink(const oss_request_options_t *options,
const aos_string_t *bucket,
const aos_string_t *symlink_object,
const aos_string_t *target_object,
aos_table_t *headers,
aos_table_t **resp_headers)
{
aos_status_t *s = NULL;
aos_http_request_t *req = NULL;
aos_http_response_t *resp = NULL;
aos_table_t *query_params = NULL;
char* targname = NULL;
headers = aos_table_create_if_null(options, headers, 0);
query_params = aos_table_create_if_null(options, query_params, 0);
apr_table_add(query_params, OSS_REQ_PARAM_SYMLINK, ""); // symlink request key without value
targname = aos_pstrdup(options->pool, target_object);
apr_table_add(headers, OSS_SYMLINK_TAEGET, targname);
oss_init_object_request(options, bucket, symlink_object, HTTP_PUT,
&req, query_params, headers, NULL, 0, &resp);
s = oss_process_request(options, req, resp);
oss_fill_read_response_header(resp, resp_headers);
return s;
}
aos_status_t *oss_get_symlink(const oss_request_options_t *options,
const aos_string_t *bucket,
const aos_string_t *symlink_object,
aos_table_t *headers,
aos_table_t **resp_headers)
{
aos_status_t *s = NULL;
aos_http_request_t *req = NULL;
aos_http_response_t *resp = NULL;
aos_table_t *query_params = NULL;
headers = aos_table_create_if_null(options, headers, 0);
query_params = aos_table_create_if_null(options, query_params, 0);
apr_table_add(query_params, OSS_REQ_PARAM_SYMLINK, ""); // symlink request key without value
oss_init_object_request(options, bucket, symlink_object, HTTP_GET,
&req, query_params, headers, NULL, 0, &resp);
s = oss_process_request(options, req, resp);
oss_fill_read_response_header(resp, resp_headers);
return s;
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
void put_object_symlink()
{
aos_pool_t *p = NULL;
aos_string_t bucket;
aos_string_t symlink_object;
aos_string_t target_object;
int is_cname = 0;
aos_table_t *headers = NULL;
aos_table_t *resp_headers = NULL;
oss_request_options_t *options = NULL;
aos_list_t buffer;
aos_buf_t *content = NULL;
char *str = "";
aos_status_t *s = NULL;
char* pbuf = NULL;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_sample_request_options(options, is_cname);
headers = aos_table_make(p, 1);
apr_table_set(headers, "x-oss-meta-author", "oss");
aos_str_set(&bucket, BUCKET_NAME);
aos_str_set(&symlink_object, "obj_link");// 符号链接名
aos_str_set(&target_object, "obj_name"); // 目标对象名
aos_list_init(&buffer);
content = aos_buf_pack(options->pool, str, strlen(str));
aos_list_add_tail(&content->node, &buffer);
s = oss_put_symlink(options, &bucket, &symlink_object, &target_object, headers, &resp_headers);
if (aos_status_is_ok(s)) {
printf("put object symlink succeeded\n");
}
else {
printf("put object symlink failed\n");
}
aos_pool_destroy(p);
}
void get_object_symlink()
{
aos_pool_t *p = NULL;
aos_string_t bucket;
aos_string_t symlink_object;
int is_cname = 0;
aos_table_t *headers = NULL;
aos_table_t *resp_headers = NULL;
oss_request_options_t *options = NULL;
aos_list_t buffer;
aos_buf_t *content = NULL;
char *str = "";
aos_status_t *s = NULL;
char* pLink = NULL;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_sample_request_options(options, is_cname);
headers = aos_table_make(p, 1);
apr_table_set(headers, "x-oss-meta-author", "oss");
aos_str_set(&bucket, BUCKET_NAME);
aos_str_set(&symlink_object, "obj_link");
aos_list_init(&buffer);
content = aos_buf_pack(options->pool, str, strlen(str));
aos_list_add_tail(&content->node, &buffer);
s = oss_get_symlink(options, &bucket, &symlink_object, headers, &resp_headers);
if (aos_status_is_ok(s))
{
printf("get object symlink succeeded\n");
pLink = apr_table_get(resp_headers, "x-oss-symlink-target");
}
else
{
printf("get object symlink failed\n");
}
aos_pool_destroy(p);
}