文档

PutDcdnKvWithHighCapacity - 设置KV存储空间的单个大容量键值对

更新时间:

接口说明

本接口与 PutDcdnKv 的功能一样,只是允许上传更大请求体。当请求体较小时推荐直接使用 PutDcdnKv 接口,从而减少服务端处理时间。本接口需要使用 SDK 进行调用。以 golang SDK 为例,需要使用 PutDcdnKvWithHighCapacityAdvance 函数进行调用。

func TestPutDcdnKvWithHighCapacity() {
	// 配置初始化
	cfg := new(openapi.Config)
	cfg.SetAccessKeyId("xxxxxxxxx")
	cfg.SetAccessKeySecret("xxxxxxxxxx")
	cli, err := NewClient(cfg)
	if err != nil {
		return err
	}
	runtime := &util.RuntimeOptions{}

	// 构造待上传的键值对请求
	namespace := "test-put-kv"
	key := "test_PutDcdnKvWithHighCapacity_0"
	value := strings.Repeat("t", 10*1024*1024)
	rawReq := &PutDcdnKvRequest{
		Namespace: &namespace,
		Key:       &key,
		Value:     &value,
	}
	payload, err := json.Marshal(rawReq)
	if err != nil {
		return err
	}

	// 如果 payload 大于 2M,则调用大容量接口进行上传
	reqHighCapacity := &PutDcdnKvWithHighCapacityAdvanceRequest{
		Namespace: &namespace,
		Key:       &key,
		UrlObject: bytes.NewReader([]byte(payload)),
	}

	resp, err := cli.PutDcdnKvWithHighCapacityAdvance(reqHighCapacity, runtime)
	if err != nil {
		return err
	}
	return nil
}

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息

当前API暂无授权信息透出。

请求参数

名称类型必填描述示例值
Namespacestring

调用 PutDcdnKvNamespace 时指定的名称。

test_namesapce
Keystring

需要设置的键名称,最长不超过 512 个字符,不能包含空格、反斜杠(/)。

test_key
Urlstring

存储有需要设置的键值对的下载链接,此参数由调用 SDK 时自动生成,请使用 SDK 进行调用。

https://xxxobject.oss-cn-reginon.aliyuncs.com/9d91_xxxxxxxxxxx_158bb6e0f97c477791209bb46bd599f7

返回参数

名称类型描述示例值
object
Lengthinteger

键值对中的值的长度。

4
Valuestring

键的内容, 超过 256 个字符长度,将取前 100 及后 100 字符并省略中间。

test
RequestIdstring

请求 ID。

EEEBE525-F576-1196-8DAF-2D70CA3F4D2F

示例

正常返回示例

JSON格式

{
  "Length": 4,
  "Value": "test",
  "RequestId": "EEEBE525-F576-1196-8DAF-2D70CA3F4D2F"
}

错误码

HTTP status code错误码错误信息描述
400Invalid.ParameterThe specified parameter is invalid.输入参数无效
400InvalidAccount.MalformedThe specified account is invalid.账号输入不对,比如输入为空
400InvalidNameSpace.MalformedThe specified namespace is invalid.namespace输入不对,比如输入为空
400InvalidKey.MalformedThe specified key is invalid.key输入不对,比如输入为空
400InvalidKey.ExceedsMaximumThe size of the key cannot exceed 512 bytes.key长度不能超过512B
400InvalidValue.ExceedsMaximumThe size of the value cannot exceed 2,000,000 bytes.value长度不能越过2000000B
403InvalidKey.ExceedsCapacityThe maximum capacity of a single namespace cannot exceed 1 GB.namespace容量超过限制,单个namespace最大容量为1G
403Unauthorized.InvalidParametersThe specified authentication parameters are invalid.鉴权参数输入错误
403Unauthorized.InvalidTimeThe specified authentication time is invalid.鉴权时间参数格式错误
403Unauthorized.InvalidTokenToken authentication failed.鉴权token校验失败
403Unauthorized.InvalidResourceResource authentication failed.资源校验失败
404InvalidAccount.NotFoundThe specified account does not exist.账号不存在,未创建
404InvalidNameSpace.NotFoundThe specified namespace does not exist.namespace不存在
404InvalidKey.NotFoundThe specified key does not exist.请求的key不存在
406InvalidNameSpace.DuplicateThe specified namespace already exists.namespace已存在
406InvalidNameSpace.QuotaFullThe maximum number of namespaces is exceeded.namespace个数超过quota限制
406InvalidKey.QuotaFullThe maximum number of keys is exceeded.key个数超过quota限制
429TooManyRequestsToo many requests are submitted.请求速率过快
429TooQuickRequestsRequest for putting or deleting keys are frequently submitted.key put/delete操作太频繁

访问错误中心查看更多错误码。

  • 本页导读 (1)