javascript - 节点 WPAPI 媒体无法上传“rest_upload_no_data”
问题描述
我在节点 WPAPI 中遇到问题。它不会上传照片。
它可以创建帖子,但不能上传图片(internal 、 uri 和 file:// path ),这些都不起作用。
给我带来问题的是自定义图像字段,其中包含可重复类型的图像和描述。
错误消息是“rest_upload_no_data”。为什么它无法接收数据?
await wp.setHeaders({ Authentication: `Bearer ${token}` });
// Selection
await wp
.createMission()
.create({
title: 'testing11111',
status: 'publish',
})
.then(async (post) => {
console.log('come to result');
console.log(post);
const filePath = '../images/note.png';
return wp
.media()
.file(filePath)
.create({
title: 'Amazing featured image',
post: post.id,
})
.then((media) => {
console.log(`Media uploaded with ID #${media.id}`);
});
})
.catch(async (err) => {
console.log(err);
const error = err.message;
throw error;
});
});
解决方案
推荐阅读
- javascript - 如何处理参数选项?
- reactjs - 为什么我的网站没有重定向到社交网站而是 mydomain/facebook?
- db2 - 从 BPM 升级到 BAW 之前的 DB2 数据库备份
- ios - Xcode LLDB 可以在 Swift 中观察 Object-C 变量吗?
- php - 限制对 WordPress 文件的直接访问
- python - Python socket.gaierror:[Errno 11001] getaddrinfo 失败
- python - Python pyautogui bot 工作一段时间后出现 TypeError: cannot unpack non-iterable NoneType object 解决方法
- python - 如何在 Python 中获取两个浮点值数据框之间的百分比相似度?
- python - ModuleNotFoundError:没有名为“dmidecode”的模块
- ios - 在 MVP 架构中将数据传递给 detailVC