Google 文档 rails
Google docs with rails
我是 rails 的新手,我希望将 google 文档与现有的 rails 项目集成。我想在用户单击按钮时为他创建一个新的 google 文档。是否有任何预先存在的宝石?任何帮助将不胜感激
查看官方 google 客户端 gem ruby google-api-client。
文档中的用法示例
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')
我是 rails 的新手,我希望将 google 文档与现有的 rails 项目集成。我想在用户单击按钮时为他创建一个新的 google 文档。是否有任何预先存在的宝石?任何帮助将不胜感激
查看官方 google 客户端 gem ruby google-api-client。 文档中的用法示例
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')