0007-00000012

更新时间:
复制 MD 格式

Problem description

OSS returns an error when the callbackBodyType field in the callback parameter contains a value that is not a string.

Causes

The callback parameter in an upload request is Base64-encoded. After decoding, the result is a JSON object. OSS validates each field in that JSON object, and callbackBodyType must be a string. If the value is any other type — such as a number — OSS returns an error.

callbackBodyType sets the Content-Type header in the callback request. Valid values:

ValueNotes
application/x-www-form-urlencodedDefault
application/json

Examples

The following shows a decoded callback parameter with an invalid callbackBodyType value.

IncorrectcallbackBodyType is a number, not a string:

{
  "callbackUrl": "www.oss-callback.com/test.php",
  "callbackBody": "{\"mimeType\":${mimeType},\"size\":${size}}",
  "callbackBodyType": 123
}

CorrectcallbackBodyType is a string:

{
  "callbackUrl": "www.oss-callback.com/test.php",
  "callbackBody": "{\"mimeType\":${mimeType},\"size\":${size}}",
  "callbackBodyType": "application/x-www-form-urlencoded"
}

Solutions

Set callbackBodyType to "application/x-www-form-urlencoded" or "application/json". If you omit the field, OSS defaults to application/x-www-form-urlencoded.

References