我是rails的新手,我希望将google docs与现有的rails项目集成。我想为用户点击按钮时创建一个新的Google文档。是否有相同的预先存在的宝石?任何帮助将不胜感激
答案 0 :(得分:2)
查看ruby google-api-client的官方google客户端gem。 文档中的使用示例
require 'google/apis/drive_v2'
Drive = Google::Apis::DriveV2 # Alias the module
drive = Drive::DriveService.new
drive.authorization = ... # See Googleauth or Signet libraries
# Search for files in Drive (first page only)
files = drive.list_files(q: "title contains 'finances'")
files.items.each do |file|
puts file.title
end
# Upload a file
metadata = Drive::File.new(title: 'My document')
metadata = drive.insert_file(metadata, upload_source: 'test.txt', content_type: 'text/plain')
# Download a file
drive.get_file(metadata.id, download_dest: '/tmp/myfile.txt')