无法下载附加到项目的 Podio 文件

Podio file attached to item cannot be downloaded

我在尝试下载跑道项目的附件时遇到问题:

podio.request('get', '/file/{file_id}/raw').then(console.log);

以上程序显示:

{}

这是一个 JSON 字符串化的空对象(而不是原始文件内容)。

详情:

问题:您知道这是什么问题吗?我怎样才能下载原始附件?

编辑:附加信息

如果我使用以下命令请求单个文件元数据:

podio.request('get', '/file/1234').then(console.log);

我得到一个包含许多字段的文件 JSON 对象,但 不是 文件内容 :

{
  ...
  link: 'https://files.podio.com/1234',
  file_id: 1234,
  ...
}

如我对@stengaard 的评论所述,如果我尝试为上述 link 请求 API,响应如下:

{ [PodioNotFoundError: [object Object]]
  message:
   { error_parameters: {},
     error_detail: null,
     error_propagate: false,
     request:
      { url: 'http://api.podio.com/1234',
        query_string: '',
        method: 'GET' },
     error_description: 'No matching operation could be found. The path \'/1234\' was not found..',
     error: 'not_found' },
  status: 404,
  url: 'https://api.podio.com:443/1234',
  name: 'PodioNotFoundError' }

要使用 GET /file/{file_id}/raw 端点,您需要具有更高信任级别的 API 密钥。

改为使用 GET /file/{file_id} 端点。它包含一个 link 属性(一个 URL),您应该遵循它来获取文件内容。

link 属性将类似于:https://files.podio.com/{file_id}。要获取文件,请执行 https://files.podio.com/{file_id}?oauth_token={oauth_token}。其中 OAuth 令牌与用于 GET /file/{file_id} 的令牌相同。如果您知道文件 ID(例如来自 GET /item/{item_id},您可以跳过 GET /file/{file_id} 并直接联系 files.podio.com。(注意:您也可以设置 Authorization: OAuth2 {oauth_token} header 如果您不喜欢在 URL 参数中传递身份验证令牌,请在您的 HTTP 请求中。)

有关如何使用它的示例,请参阅 https://github.com/podio/podio-js/blob/master/lib/general.js#L11

通常在 JS 客户端中,如果您使用 podio 作为跑道 API object,OAuth 令牌将位于此处:

podio.authObject.accessToken

所以要在 nodejs 中获取文件的原始内容:

var url = 'https://files.podio.com/'+file_id+'?oauth_token='+podio.authObject.accessToken;
request(url, function (err, fileContent) {
    // use fileContent here, write to a file, etc...
});

您的请求似乎有误。 请尝试以下方法并从其响应中获取原始文件内容。

podio.request('get', '/file/{file_id}').then(console.log);

仅供参考,我们无法通过筛选项目来获取文件。我们需要单独请求 /item/{item_id} 以获取文件 属性,如您所说。