1

我正在使用 box-api gem 开发一个 Ruby on Rails 应用程序。我想为特定用户显示 box.net 文件和文件夹。到目前为止,我已经成功地验证了一个用户并显示了他的根文件和文件夹。如果我单击一个文件夹,我想显示该文件夹的内容。到目前为止,如果我单击一个文件夹,我会将文件夹 ID 保存在参数中,但我找不到该特定文件夹的内容。那么,如果我知道 folder_id 如何到达该文件夹?我试过这样的事情:

 account = Box::Account.new(BOXNET_KEY)
 account.authorize(auth_token: current_user.boxnet_auth_token)
 @account = account
 root = @account.root
 folder = root.folders[params[:folder_id].to_i]
4

1 回答 1

0

box-api gem 已弃用,他们建议您使用ruby​​-box API。

根据文档列出您需要的文件:

require 'ruby-box'

session = RubyBox::Session.new({
  client_id: 'your-client-id',
  client_secret: 'your-client-secret',
  access_token: 'access-token'
})

client = RubyBox::Client.new(session)
files = client.folder('/image_folder').files # all files in a folder.
folders = client.root_folder.folders # all folders in the root directory.
files_and_folders = client.folder('files').items # all files and folders in /files

首先确保您已刷新访问令牌,如自述文件中所述。

于 2013-08-22T11:31:03.143 回答