async function writeDB() {
const url = "https://api.weixin.qq.com/tcb/databasemigrateimport?access_token=xxx";
const abc = {
"env": "xxx",
"collection_name": "school-hourse",
"file_path":"/temp/2133000963/equal/2300011379.json",
"file_type":1,
"stop_on_error": false,
"conflict_mode": 2
}
const abcd = await newRequest({
url: url,
method: "POST",
json: true,
headers: {
"content-type": "application/json",
},
body: abc
});
const {errcode, job_id} = abcd.body;
if (errcode === 0) {
setTimeout(async () => {
// 查询任务状态
const jobUrl = "https://api.weixin.qq.com/tcb/databasemigratequeryinfo?access_token=xxx";
const jobResult = await newRequest({
url: jobUrl,
method: "POST",
json: true,
headers: {
"content-type": "application/json",
},
body: {
env: "xxx",
job_id
}
});
console.log('jobResult', jobResult.body)
}, 2000)
}
}
需求:利用云函数导入位于云存储中的csv文件至云数据库中。post 方法调用 "https://api.weixin.qq.com/tcb/databasemigratequeryinfo?access_token=xxx",相关参数是正确的,但是会报如下的错误。麻烦帮忙看下,当前卡在这里了。
具体报错:“导入数据任务(id:6528678)异常,错误信息:导入文件大小为0,请确认文件是否正确或文件在cos中权限是否正确”
{
errcode: 0,
errmsg: 'ok',
status: 'fail',
record_success: 0,
record_fail: 0,
error_msg: '导入数据任务(id:6528678)异常,错误信息:导入文件大小为0,请确认文件是否正确或文件在cos中权限是否正确',
file_url: ''
}
filepath 写云存储的cloudId