Google Drive API:没有适用于* .zip文件的downloadURL

时间:2015-07-29 02:00:47

标签: python google-drive-api

我尝试通过Python中的Google Drive Rest API下载zip文件,但我的API调用不会返回downloadURL。我使用的代码仍然非常接近官方文档。

credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('drive', 'v2', http=http)
results= service.children().list(folderId=shapes_folder).execute()
items = results.get('items', [])
shape_ids = []
if not items:
    print 'No files found.'
else:
    for item in items:
        shape_ids.append(item['id'])
print shape_ids
all_files = service.files().list().execute()
items = all_files.get('items', [])
if not items:
    print 'No files found.'
else:
    for item in items:
        if item['title'] == shape_file_name:
            shape_file_id = item['id']
            shape_file = service.files().get(fileId=shape_file_id).execute()
            print shape_file
            download_url = shape_file["downloadUrl"]
            print download_url
            if download_url:
                resp, content = service._http.request(download_url)
                if resp.status == 200:
                    print 'Status: %s' % resp
                    return content
                else:
                    print 'An error occurred: %s' % resp
                    return None
            else:
            # The file doesn't have any content stored on Drive.
                return None

知道我做错了什么吗?谢谢你!

0 个答案:

没有答案