【问题标题】:Sending html canvas binary data to Google Photos API将 html canvas 二进制数据发送到 Google Photos API
【发布时间】:2018-06-14 19:24:50
【问题描述】:

我正在尝试将图像从画布上传到 Google 相册:

第 1 步:Upload binary image data

POST https://photoslibrary.googleapis.com/v1/uploads
Content-type: application/octet-stream
Authorization: Bearer OAuth2_TOKEN
X-Goog-Upload-File-Name: FILENAME
MEDIA_BINARY_DATA

我的MEDIA_BINARY_DATA

function get_binary_data_from_canvas(){
  var canvas = document.getElementById("canvas-upload");
  return canvas.toDataURL(); // <- my binary data
}

我得到一个 uploadToken

第 2 步:Create Media Item

我使用上一步获得的 uploadToken 发送有效请求。

在我得到的回复中:

 "NOT_IMAGE: There was an error while trying to create this media item"

那么从 HTML 画布生成二进制数据的正确方法是什么?

【问题讨论】:

    标签: javascript canvas google-photos google-photos-api


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-22
      • 2017-11-14
      • 2012-09-10
      • 2019-10-04
      • 1970-01-01
      • 1970-01-01
      • 2015-10-24
      相关资源
      最近更新 更多