请求分片上传
您可以使用本接口创建分片上传任务,请求分片上传。
任务创建后,需使用 /file/transfer/upload/依次上传分片文件。
v1.2与v1.3版本对比
以下表格概括了 v1.2与v1.3接口的变化。
``xtable
|变化内容{30%}|v1.2{35%}|v1.3{35%}|
|---|---|---|
|接口路径|/v1.2/file/start/upload/|/v1.3/file/start/upload/|
|请求参数类型|advertiser_id: number|advertiser_id`: string|
## 请求
**地址** https://business-api.tiktok.com/open_api/v1.3/file/start/upload/
**方法** POST
**Header**
``` xtable
|字段|类型|描述|
|--- |--- |--- |
|Access-Token {必填}|string|授权访问令牌。可以通过[获取访问令牌](https://ads.tiktok.com/marketing_api/docs?id=1738373164380162)接口获取。|
|Content-Type {必填}|string|请求信息类型。<br>允许格式:`application/json`。|
参数
|字段|类型|描述|
|---|---|---|
|advertiser_id {必填}|string|广告主ID。|
|size {必填}|number|文件大小(以字节为单位,不小于20MB)。|
|content_type {必填}|string|文件类型。枚举值:`image`, `video`, `music`。|
|name|string|文件名称,不超过100个字符。|
示例
(code Curl curl)
curl --location --request POST 'https://business-api.tiktok.com/open_api/v1.3/file/start/upload/' \
--header 'Access-Token: {{Access-Token}}' \
--header 'Ccontent-Ttype: application/json' \
--data-raw '{
"advertiser_id": "{{advertiser_id}}",
"size": {{size}},
"content_type": "video",
"name": "{{name}}"
}'
(/code);
返回
|字段|类型|描述|
|---|---|---|
|code |number|返回码,详见[附录-返回码](https://ads.tiktok.com/marketing_api/docs?id=1737172488964097)。|
|message |string|返回信息,详见[附录-返回码](https://ads.tiktok.com/marketing_api/docs?id=1737172488964097)。|
|data|object|返回数据。|
#|upload_id|string|上传任务ID,后续请求都需要填入这个ID。|
#|file_name|string|文件名称,不超过100个字符。|
#|start_offset|number|第一个分片的开始偏移量。|
#|end_offset|string|第一个分片的结束偏移量。|
|request_id|string|请求的日志id,唯一标识一个请求。|
示例
(code Success-Response http)
HTTPS/1.1 200 OK
{
"Message": "OK",
"Code": 0,
"Data": {
"UploadId": "{{upload_id}}",
"FileName": "{{file_name}}",
"StartOffset": 0,
"EndOffset": 20971520
},
"RequestId": "{{request_id}}"
}
(/code);