无法在js中的Google云端硬盘上上传图片 修改点:修改后的请求正文:注意:

问题描述

我正在尝试使用oauth令牌和提取网址将图像文件上传到Google驱动器。 https://developers.google.com/drive/api/v3/manage-uploads 执行分段上传,即HTTP。 当我尝试上传时,提取网址响应会返回状态200,并且在Google驱动器中,文件在那里。但是看不到(无法识别img)。

这是我的标题

method: post 
Authorization: `Bearer ${token}`
Content-Type: `multipart/related; boundary=${boundaryString}`
Content-Length: ${body.Length}

这是我的身体

--`${boundaryString}`
Content-Type: application/json; charset=UTF-8

{"name":"myimage.png","description":"Upload image","mimeType":"image/png"}

--`${boundaryString}`
Content-Type: image/png; Content-Transfer-Encoding: base64

data:image/png;base64,iVBO......TkSuQmCC
--`${boundaryString}`--

响应:

status: 200 url: "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"
body: {
  id: "~~~~"
  kind: "drive#file"
  mimeType: "image/png"
  name: "myimage.png"

当我开车时,它存在。它是详细信息收集(名称,描述,mimeType), 但无法像其他图像一样识别。(不支持文件格式。) 当我检查<img src ="data:image/png;base64,iVBO......TkSuQmC" />时,它起作用。 可以告诉我是什么问题吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)