我正在使用 Google Ruby API 客户端下载 Google Drive 文件(使用 downloadUrl)。我能够成功下载文件,但接下来我想提示 Web 用户将文件保存到本地(到他选择的位置)。在下面的代码之后我该怎么做才能实现这一目标?
client = Google::APIClient.new
drive = client.discovered_api('drive', 'v2')
client.authorization.client_id = ENV["GOOGLE_CLIENT_ID"]
client.authorization.client_secret = ENV["GOOGLE_CLIENT_SECRET"]
client.authorization.redirect_uri = '...'
client.authorization.access_token = '...'
client.authorization.scope = https://www.googleapis.com/auth/drive
result = client.execute(
:api_method => drive.files.get,
:version => 'v2',
:parameters => { 'fileId' => "..."}
)
download_url = result.data.downloadUrl
if download_url
fileResult = client.execute(:uri => download_url)
else
#HANDLE ERRORS
....
end
# WHAT TO ADD HERE TO PROMPT USER TO SAVE THE FILE LOCALLY?