主题
通过云盘文档创建文档
通过用户提供的云盘文档下载地址,下载该文档,创建到指定目录下,支持的类型见类型说明
基本信息
请求方法:POST
请求路径:/api/v1/openapi/personal/files/cloud
请求主机:developer.kdocs.cn
限流频次
应用类型 | 限额 |
---|---|
测试应用 | 500 次/天 |
正式应用 | 100,000 次/天 |
权限范围
权限值 | 显示名称 | 权限说明 |
---|---|---|
create_personal_files | 创建个人文档 | 创建个人文档 |
Query 参数
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
access_token | 是 | string |
Body 参数
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
url | 是 | string | 云盘文档的下载地址 |
filename | 是 | string | 文档名称,包含扩展名,例如:demo.ksheet |
parent_id | 否 | string | 文档所属目录 id,与 parent_path 互斥,同时存在时优先使用 parent_id |
parent_path | 否 | string[] | 文档所属目录,与 parent_id 互斥,同时存在时优先使用 parent_id |
path_from_root | 否 | boolean | parent_path 参数是否从 我的文档 开始,默认否 |
参数说明:
提示
在金山文档,存储用户个人文档的根目录为我的文档
。
应用名 | path_from_root | parent_path | 文档创建位置 |
---|---|---|---|
foo | false | [] | /我的文档/应用/foo |
foo | false | ["bar", "baz"] | /我的文档/应用/foo/bar/baz |
foo | true | [] | /我的文档 |
foo | true | ["bar", "baz"] | /我的文档/bar/baz |
提示
我们推荐您将文档创建到您的应用目录下,方便用户理解和管理。
文档类型说明
文档类型 | 扩展名 |
---|---|
在线表格 | .ksheet |
轻维表 | .dbt |
文档 | .otl |
演示 | .pptx .ppt |
WPS 文字 | .docx .doc |
WPS 表格 | .xlsx .xls |
返回参数
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
code | 是 | integer | 错误码 |
data | 是 | data {} | 响应数据 |
示例
请求示例
curl --request POST \
--url 'https://developer.kdocs.cn/api/v1/openapi/personal/files/cloud?access_token=kvqxrspxjctdojjqdildjhonzwusaquc' \
--header 'Content-Type: application/json' \
--data '{"url":"https://download.foo.bar/file/1","filename":"demo.ksheet","parent_path":["path1","path2"]}'
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"url\":\"https://download.foo.bar/file/1\",\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}");
Request request = new Request.Builder()
.url("https://developer.kdocs.cn/api/v1/openapi/personal/files/cloud?access_token=kvqxrspxjctdojjqdildjhonzwusaquc")
.post(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://developer.kdocs.cn/api/v1/openapi/personal/files/cloud?access_token=kvqxrspxjctdojjqdildjhonzwusaquc"
payload := strings.NewReader("{\"url\":\"https://download.foo.bar/file/1\",\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import http.client
conn = http.client.HTTPSConnection("developer.kdocs.cn")
payload = "{\"url\":\"https://download.foo.bar/file/1\",\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}"
headers = { 'Content-Type': "application/json" }
conn.request("POST", "/api/v1/openapi/personal/files/cloud?access_token=kvqxrspxjctdojjqdildjhonzwusaquc", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://developer.kdocs.cn/api/v1/openapi/personal/files/cloud?access_token=kvqxrspxjctdojjqdildjhonzwusaquc",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"url\":\"https://download.foo.bar/file/1\",\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
const data = JSON.stringify({
"url": "https://download.foo.bar/file/1",
"filename": "demo.ksheet",
"parent_path": [
"path1",
"path2"
]
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://developer.kdocs.cn/api/v1/openapi/personal/files/cloud?access_token=kvqxrspxjctdojjqdildjhonzwusaquc");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
const http = require("https");
const options = {
"method": "POST",
"hostname": "developer.kdocs.cn",
"port": null,
"path": "/api/v1/openapi/personal/files/cloud?access_token=kvqxrspxjctdojjqdildjhonzwusaquc",
"headers": {
"Content-Type": "application/json"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
url: 'https://download.foo.bar/file/1',
filename: 'demo.ksheet',
parent_path: ['path1', 'path2']
}));
req.end();
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://developer.kdocs.cn/api/v1/openapi/personal/files/cloud?access_token=kvqxrspxjctdojjqdildjhonzwusaquc");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"url\":\"https://download.foo.bar/file/1\",\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}");
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://developer.kdocs.cn/api/v1/openapi/personal/files/cloud?access_token=kvqxrspxjctdojjqdildjhonzwusaquc");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\"url\":\"https://download.foo.bar/file/1\",\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
返回示例
{
"code": 0,
"data": {
"id": {
"open_id": "JxdxSDJpnZKRRr0dEKZRuKzClBub7Uz7m1caY_YSxZg",
"union_id": "-9Yu8Qo2oJirjqhvNofycKzClBub7Uz7m1caY_YSxZg"
},
"space": "ok"
}
}
错误码
请参考错误码说明