我搜索谷歌但没有得到任何结果,我的代码如下:
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
# this function used inside function do_the_work(drive)
def upload_gd(media_file, drive):
print 'Try uploading ' + media_file
xfile = drive.CreateFile()
xfile.SetContentFile(media_file)
xfile.Upload()
print('Created file %s with mimeType %s' % (xfile['title'], xfile['mimeType']))
permission = xfile.InsertPermission({
'type': 'anyone',
'value': 'anyone',
'role': 'reader'})
print 'Sharable link (to view) is:' + xfile['alternateLink']
print 'Get direct link'
file_id = xfile['alternateLink'].split('/')[-2]
print 'file ID: ' + file_id
d_link = 'https://drive.google.com/uc?export=download&id=' + file_id
print 'Direct link is: ' + d_link
return d_link
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
do_the_work(drive)
而且,我获得的文件权限是:
但是,我只希望任何人都可以查看,但无法找到: