Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python将大于70 MB的文件上载到google drive_Python_Google Drive Api - Fatal编程技术网

使用Python将大于70 MB的文件上载到google drive

使用Python将大于70 MB的文件上载到google drive,python,google-drive-api,Python,Google Drive Api,嗨,我试图上传文件到谷歌驱动器使用以下代码 def upload_file(self,file_name,path): parents = None if not path == None: parents = self.create_path(path) mime_type = self.get_mime_type_for(file_name) file_id = self.check_file_exist(file_name,parents,

嗨,我试图上传文件到谷歌驱动器使用以下代码

def upload_file(self,file_name,path):

    parents = None
    if not path == None:
        parents = self.create_path(path)
    mime_type = self.get_mime_type_for(file_name)
    file_id = self.check_file_exist(file_name,parents,mime_type)
    if file_id == None:

        print "creating file...........",file_name                      
        print "mime_type",mime_type
        media = MediaFileUpload(file_name, mimetype=mime_type, resumable=True)
        body = {
            'title': file_name,
            'description': 'A test document',
            'mimeType': mime_type
        }
        if not parents == None:
            body['parents'] = [{'id': parents}]
        f = self.drive_service.files().insert(body=body, media_body=media).execute()
    else:
        print "file exists........... updating"
        self.update_file(file_id, file_name)
这段代码适用于较小的文件(测试最高可达25MB)。但是如果我试图上传大文件(70MB),系统会给出错误消息

回溯(最近一次呼叫最后一次):

文件“googledrive.py”,第176行,在

gd.upload_文件(“test.mp4”,“/media/media”)

上传文件中第122行的文件“googledrive.py”

f=self.drive\u service.files().insert(body=body,media\u body=media).execute()

文件“/usr/local/lib/python2.7/dist packages/oauth2client/util.py”,第132行,位于位置包装器中

已包装退货(*args,**kwargs)

文件“/usr/local/lib/python2.7/dist packages/apiclient/http.py”,第688行,在execute中

_,body=self.next\u chunk(http=http,num\u retries=num\u retries)

文件“/usr/local/lib/python2.7/dist packages/oauth2client/util.py”,第132行,位于位置包装器中

已包装退货(*args,**kwargs)

文件“/usr/local/lib/python2.7/dist-packages/apiclient/http.py”,第867行,在下一块中

页眉=页眉)

文件“/usr/local/lib/python2.7/dist packages/oauth2client/util.py”,第132行,位于位置包装器中

已包装退货(*args,**kwargs)

文件“/usr/local/lib/python2.7/dist packages/oauth2client/client.py”,第490行,在新请求中

重定向、连接(U类型)

请求中的文件“/usr/local/lib/python2.7/dist packages/httplib2/init.py”,第1570行

(响应,内容)=self.\u请求(conn,authority,uri,request\u uri,method,body,header,重定向,cachekey)

文件“/usr/local/lib/python2.7/dist packages/httplib2/init.py”,第1317行,在请求中

(响应,内容)=自连接请求(连接,请求uri,方法,正文,标题)

文件“/usr/local/lib/python2.7/dist packages/httplib2/init.py”,第1286行,在连接请求中

response=conn.getresponse()

getresponse中的文件“/usr/lib/python2.7/httplib.py”,第1045行

response.begin()

文件“/usr/lib/python2.7/httplib.py”,第409行,在begin中

版本、状态、原因=self.\u读取\u状态()

文件“/usr/lib/python2.7/httplib.py”,第373行,处于读取状态

升起状态行(行)


如果您的上传时间超过一小时,您的令牌可能会过期,您的下载将失败。这是一个众所周知的问题


另外,请参见

要多长时间才能失败?可能是相关的:根据文档,它最多应该有10个Gig。
httplib.BadStatusLine: ''