2016-11-27 129 views
0

我是新來的鐵軌,我正在尋找整合谷歌文檔與現有的鐵路項目。我想爲用戶創建一個新的谷歌文檔,當他點擊一個按鈕。有沒有相同的預先存在的寶石?任何幫助將不勝感激谷歌文檔與鐵軌

+0

有大量的寶石出現,只需搜索'谷歌文檔紅寶石'。您還可以嘗試Google Drive REST API:https://developers.google.com/drive/v3/web/quickstart/ruby –

回答

2

看一個官方的谷歌客戶端寶石紅寶石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')