Closed szllzs closed 2 years ago
你用的是哪个上传接口,上传接口有两个。同时贴一下输出的出错信息。
接口:uploadRetPCSFile = api.upload_file(f, remotepath, callback=upload_callback)
报错堆栈:
文件上传进度:11%(279666688/2371981470) Traceback (most recent call last):
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 394, in _make_request
conn.request(method, url, httplib_request_kw)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\urllib3\connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\http\client.py", line 1257, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\http\client.py", line 1303, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\http\client.py", line 1252, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\http\client.py", line 1051, in _send_output
self.send(chunk)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\http\client.py", line 973, in send
self.sock.sendall(data)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\ssl.py", line 1204, in sendall
v = self.send(byte_view[count:])
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\ssl.py", line 1173, in send
return self._sslobj.write(data)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\requests\adapters.py", line 440, in send
resp = conn.urlopen(
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\urllib3\util\retry.py", line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
raise value.with_traceback(tb)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 394, in _make_request
conn.request(method, url, httplib_request_kw)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\urllib3\connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\http\client.py", line 1257, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\http\client.py", line 1303, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\http\client.py", line 1252, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\http\client.py", line 1051, in _send_output
self.send(chunk)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\http\client.py", line 973, in send
self.sock.sendall(data)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\ssl.py", line 1204, in sendall
v = self.send(byte_view[count:])
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\ssl.py", line 1173, in send
return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\baidupcs_py\baidupcs\pcs.py", line 197, in _request
resp = self._session.request(
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\requests\sessions.py", line 529, in request
resp = self.send(prep, send_kwargs)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\requests\sessions.py", line 645, in send
r = adapter.send(request, kwargs)
File "C:\Users\szl\AppData\Local\Programs\Python\Python39-32\lib\site-packages\requests\adapters.py", line 501, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "P:/88db8/vnr/learn/frida/project/移动懒人包/apppack/apkrepack/ps2apkrepack-noimg.py", line 401, in
BaiduPCSApi.upload_file
只能用于上传2G以下的文件。建议100MB以上的文件用分片上传 BaiduPCSApi.upload_slice
+ BaiduPCSApi.combine_slices
。
大致过程如下:
from io import BytesIO
from baidupcs_py import BaiduPCSApi
from baidupcs_py.commands.upload import DEFAULT_SLICE_SIZE
api = BaiduPCSApi(...)
fd = open("some-file", "rb")
slice_md5s = []
while True:
buf = fd.read(DEFAULT_SLICE_SIZE)
if not buf:
break
md5 = api.upload_slice(BytesIO(buf))
slice_md5s.append(md5)
api.combine_slices(slice_md5s, "/to/here")
非常感谢
Prerequisites / 报告前提 Before you report a bug, please let the bug to be reproduced at the latest verion of BaiduPCS-Py. 在你提交报告前,请在 BaiduPCS-Py 的最新版本上复现问题。
At sometimes, there are errors occured by an expired cookie. Before you commit the report, please to check whether cookies are expired. 有时一些错误是由于某个 cookie 超期导致的。在你提交报告前,请先检查你的 cookies 是否超期。
Describe the bug / 描述 bug A clear and concise description of what the bug is. 请清楚的描述你遇到的问题。
To Reproduce / 复现问题 Steps to reproduce the behavior:
按照下面的步骤可以复现问题:
Screenshots / 问题截图 If applicable, add screenshots to help explain your problem.
如果可能,请附加问题截图。
Envrionment / 运行环境
Runing log / 运行日志 Please follow steps to paste the content of file
~/.baidupcs-py/running.log
.~/.baidupcs-py/running.log
if it exists.LOG_LEVEL=DEBUG
. e.g.LOG_LEVEL=DEBUG BaiduPCS-Py upload /abc /
~/.baidupcs-py/running.log
after the bug occurs.请按照下面的步骤贴出运行日志
~/.baidupcs-py/running.log
中的内容。~/.baidupcs-py/running.log
,如果存在。LOG_LEVEL=DEBUG
。 例如:LOG_LEVEL=DEBUG BaiduPCS-Py upload /abc /
~/.baidupcs-py/running.log
中的内容。Additional context / 补充内容 Add any other context about the problem here. 在这里增加补充内容。