ly0 / baidupcsapi

百度网盘api
MIT License
1.21k stars 234 forks source link

上传文件无效 #81

Open ShayneLee8 opened 6 years ago

ShayneLee8 commented 6 years ago

不知为何我上传文件的进度条没有显示, 网盘也没有上传的文件。 100% |> | Time: 0:00:00 100% |> | Time: 0:00:00 显示一下就100%, 实际没有上传。 部分代码 test_file = open('test.rar','rb').read() ret = pcs.upload('/myowns/testPan/',test_file,'test.txt',callback=ProgressBar())

ShayneLee8 commented 6 years ago

当没有用 callback 时
ret = pcs.upload('/myowns/testPan/',test_file,'test.rar') 出现以下异常. ` Traceback (most recent call last): File "C:\lyxprogramfile\python3\lib\site-packages\urllib3\response.py", line 572, in _update_chunk_length self.chunk_left = int(line, 16) ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\lyxprogramfile\python3\lib\site-packages\urllib3\response.py", line 331, in _error_catcher yield File "C:\lyxprogramfile\python3\lib\site-packages\urllib3\response.py", line 637, in read_chunked self._update_chunk_length() File "C:\lyxprogramfile\python3\lib\site-packages\urllib3\response.py", line 576, in _update_chunk_length raise httplib.IncompleteRead(line) http.client.IncompleteRead: IncompleteRead(0 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\lyxprogramfile\python3\lib\site-packages\requests\models.py", line 749, in generate for chunk in self.raw.stream(chunk_size, decode_content=True): File "C:\lyxprogramfile\python3\lib\site-packages\urllib3\response.py", line 461, in stream for line in self.read_chunked(amt, decode_content=decode_content): File "C:\lyxprogramfile\python3\lib\site-packages\urllib3\response.py", line 665, in read_chunked self._original_response.close() File "C:\lyxprogramfile\python3\lib\contextlib.py", line 99, in exit self.gen.throw(type, value, traceback) File "C:\lyxprogramfile\python3\lib\site-packages\urllib3\response.py", line 349, in _error_catcher raise ProtocolError('Connection broken: %r' % e, e) urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "test.py", line 24, in ret = pcs.upload('/myowns/testPan/',test_file,'test.rar') File "C:\Users\lyx\Desktop\desktop_file\baidupcsapi\baidupcsapi\api.py", line 611, in upload files=files, callback=callback, *kwargs) File "C:\Users\lyx\Desktop\desktop_file\baidupcsapi\baidupcsapi\api.py", line 126, in wrapper ret = func(args, kwargs) File "C:\Users\lyx\Desktop\desktop_file\baidupcsapi\baidupcsapi\api.py", line 475, in _request api, data=body, verify=False, headers=headers, kwargs) File "C:\lyxprogramfile\python3\lib\site-packages\requests\sessions.py", line 559, in post return self.request('POST', url, data=data, json=json, kwargs) File "C:\lyxprogramfile\python3\lib\site-packages\requests\sessions.py", line 512, in request resp = self.send(prep, send_kwargs) File "C:\lyxprogramfile\python3\lib\site-packages\requests\sessions.py", line 662, in send r.content File "C:\lyxprogramfile\python3\lib\site-packages\requests\models.py", line 827, in content self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b'' File "C:\lyxprogramfile\python3\lib\site-packages\requests\models.py", line 752, in generate raise ChunkedEncodingError(e) requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

`

ly0 commented 6 years ago

感觉更像是网络问题?