本文介绍如何删除对象标签(Object Tagging)。

对象标签使用一组键值对(Key-Value)来标记对象。对象标签的详情请参考开发指南的对象标签

以下代码用于删除对象标签:
#include <alibabacloud/oss/OssClient.h>
using namespace AlibabaCloud::OSS;

int main(void)
{
    /* 初始化OSS账号信息 */
    std::string AccessKeyId = "yourAccessKeyId";
    std::string AccessKeySecret = "yourAccessKeySecret";
    std::string Endpoint = "yourEndpoint";
    std::string BucketName = "yourBucketName";
    std::string ObjectName = "yourObjectName";

    /* 初始化网络等资源 */
    InitializeSdk();

    ClientConfiguration conf;
    OssClient client(Endpoint, AccessKeyId, AccessKeySecret, conf);
    std::shared_ptr<std::iostream> content = std::make_shared<std::stringstream>();
    *content << "test cpp sdk";
    PutObjectRequest request(BucketName, ObjectName, content);

    /* 上传文件 */
    auto outcome = client.PutObject(request);

    /* 设置对象标签 */
    Tagging tagging;
    tagging.addTag(Tag("key1", "value1"));
    tagging.addTag(Tag("key2", "value2"));
    auto putTaggingOutcome = client.SetObjectTagging(SetObjectTaggingRequest(BucketName, ObjectName, tagging));

    /* 删除对象标签 */
    auto delTaggingOutcome = client.DeleteObjectTagging(DeleteObjectTaggingRequest(BucketName, ObjectName));

    if (!delTaggingOutcome.isSuccess()) {
        /* 异常处理 */
        std::cout << "delTaggingOutcome fail" <<
        ",code:" << delTaggingOutcome.error().Code() <<
        ",message:" << delTaggingOutcome.error().Message() <<
        ",requestId:" << delTaggingOutcome.error().RequestId() << std::endl;
        ShutdownSdk();
        return -1;
    }

    /* 释放网络等资源 */
    ShutdownSdk();
    return 0;
}

删除对象标签详情请参考DeleteObjectTagging