谷歌黑客们大家好!
我正在使用 Drive Service 应用程序并成功上传文件,如下所示:
require 'googleauth'
require 'google/apis/drive_v2'
Drive = Google::Apis::DriveV2
upload_source = "/User/my_user_name/hacking.txt"
drive = Drive::DriveService.new
# Drive::AUTH_DRIVE is equal to https://www.googleapis.com/auth/drive
drive.authorization = Google::Auth.get_application_default([Drive::AUTH_DRIVE])
file = drive.insert_file({title: 'hacking.txt'}, upload_source: upload_source)
file
有很多属性,比如:下载地址
但是当我尝试打开这个download_url
在浏览器中它显示我空白屏幕。为什么我无法下载?
我想,这可能是权限问题?但是范围是正确的,并且上传成功...
答案很简单 - 我们无法从以下位置下载它file
对象,我们必须发送另一个获取请求,只需像这样下载它:
drive.get_file(file.id, download_dest: '/tmp/my_file.txt')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)