wordpress - 已上传空图像
问题描述
图片上传到 wordpress 正在上传空图片
我正在开发一个使用 wordpress API 的移动应用程序。我的应用程序使用 Nativescript-Vue 框架。我需要使用远程 WP-API 将多个图像上传到 wordpress。
var data=[];
const params = new FormData();
//params.append('file', this.value);
this.product.images.forEach(i => {
params.append('file',i.src);
console.log(i.src);
});
const axiosInstance = axios.create({
baseURL: 'https://mah.ttawor.com/wp-json/wp/v2/',
timeout: 5000,
headers: {
Authorization: this.auth_token,
'content_type':'multipart/form-data' ,
'Content-Disposition':`attachment; filename="product.jpg"`
},
});
if(this.product.images.length === 0) return;
axiosInstance.post('media',params)
.then(response => {
//console.log(response)
})
.catch(err => {
console.log(err)
})
}
不幸的是,Word Press 收到一个空白图像。任何解决方案,我都尝试过 nativescript-background-http。那也不起作用,它与 wordpress 的 oauth 有很多问题
解决方案
截至今天,{N} 不支持开箱即用的多部分数据上传。您可以关注 Github 上的开放功能请求以获取更多更新。
建议的解决方法是同时使用nativescript-background-http插件。
tns plugin add nativescript-background-http
推荐阅读
- java - 如何使用 PowerMockito 模拟 System.exit?
- node.js - 如何避免使用 discord.js api 超过速率限制?
- mysql - Bitnami 灯栈 phpmyadmin 密码
- java - 在android studio中添加两个数字时出错
- javascript - python selenium附加文件,没有要交互的元素
- arrays - 迭代状态对象
- git - 从 mac 中删除 github 凭据
- swift - 释放 LongPressGesture SwiftUI 时触发动作
- momentjs - 给定所需的工作时间和 PT 时区的工作时间,如何计算任何时区的完成日期时间
- javascript - 将数据从一张纸复制到另一张 - Google Script