javascript - 如何使用 google-api-nodejs-client 在时间轴中插入附件?

标签 javascript node.js attachment google-mirror-api

我现在正在试用 Google Glass Mirror API。我的测试应用程序是一个带有 googleapis ( https://github.com/google/google-api-nodejs-client) 的简单 node.js/express 服务器。

到目前为止,我几乎可以在没有附件的情况下成功完成时间线的几乎所有基本操作,例如列表/获取/更新/删除。以下是我如何插入时间轴卡片:

var googleapis = require('googleapis');
app.all('/timeline_insert', function(req, res) {
  var timeline = {'text': req.query.text};
  googleapis.discover('mirror', 'v1')
        .execute(function(err, client) {
      client.mirror.timeline.insert({resource: timeline})
                        .withAuthClient(oauth2client)
                .execute(function(err, result) {
          // ...
      });
  });

}

现在我想更进一步来测试附件功能。但是,我不知道如何通过 googleapis 和 node.js 使用 API。是否有插入/获取等附件操作的示例代码?我知道我总是可以使用原始 HTTP 格式来完成它。但是由于googleapis已经提供了API,所以我只想直接使用它们。谢谢。

最佳答案

基于 JavaScript 客户端库的 Node.js 客户端库没有对媒体上传的内置支持:您需要“手动”构建请求。

answer应该可以帮助您开始构建此请求。

有关 Google 媒体上传协议(protocol)的更多信息,请参阅我们的 documentation .

关于javascript - 如何使用 google-api-nodejs-client 在时间轴中插入附件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16995035/

相关文章:

php - 如何在 Apache 中同时重写和设置 header

javascript - React Native CheckBox 不工作

没有 next 的 Node.js Express 中间件函数

javascript - 断言数组减少为真

node.js - 无法理解express.js

node.js - Meteor的CollectionFS下载错误: write after end

ios 截取 View 并将其附加到邮件中

html - Outlook HTML 邮件 - 将链接项目更改为嵌入

javascript - 使用 jQuery 将实例从 View 传递到 Controller

javascript - 为什么我的数组结果不符合我的 CSS 规则?