我能够在 上获取上传令牌和 200 状态代码batchCreate。然而,详细的回应是这样的;
{
"newMediaItemResults": [
{
"uploadToken": "CAISqQMAqD4uLZF/uW6bVfUSjQTCRLEgg9ngZv9lS/VqwBw3puvDr2+FGxes9bCQ6VRS8Wd3hdm1sqmZ07CAclBbqR2S+JqRJoOS820km7RHGlZvODMcg1e+U5aFx5I+w59lz0NoyfmaUq4FQ7TqaoTqkW7vgOd2+s5z9qZtAYbqovR7+Az6xfUoZ7wZGwVnDDC0Q9Naf/Qu9qOo3yemZ/jVyE5gMpTj4jtAd+cb4DBCtWLK5cZREJUq18wiB3MqojF5Kv7UOo15dxgRTMR3lib+3s6W+BlBTc1LjZ7WSAr6PX1kA/wgxz74Cpo4neM4WRwPp5E+mSSHCGHpFzPKE8t5xpN71aOrM1d8WoT0jZApnDCAv5ggMUteli9BNSTZSPcZb7AJNUAssUKsDfb0F9NoZedDfrQZUlGH0UqYjj7X74Uk7qMtDCp2XS65LuiUNS2VCkOZydPg2Vtapvpgo/n+h2ib00+e3ci+H1+Zlo7OMH+j99TZof7p7fOdnOcQ2vF+EATdG4p6DatxFvE1op/M8hfvgVAYqV9h6aWUzxIDNKRSy1JKFcM7LO5DIA",
"status": {
"code": 3,
"message": "Failed: There was an error while trying to create this media item."
}
}
]
}
有人可以向我解释一下我做错了什么吗?
下面是上传功能的代码;
uploadImages(images, token) {
const promises = Array.from(images).map(image => {
const formData = new FormData();
formData.append('media-binary-data', image);
console.log(formData);
return axios.post(`${UPLOAD_URL}`, formData, {
headers: {
'Content-Type': "application/octet-stream",
'X-Goog-Upload-File-Name': '',
'X-Goog-Upload-Protocol': "raw",
'Authorization': `Bearer ${token}`,
},
}).then((response) => {
return axios.post('https://photoslibrary.googleapis.com/v1/mediaItems:batchCreate',
{
"newMediaItems": [
{
"description": "item-description",
"simpleMediaItem": {
"uploadToken": response.data
}
}
]
呼啦一阵风
相关分类