多年来,我在这里找到了答案,现在终于到了问我第一个问题的时候了
像在家里运行迷你服务器一样运行RPI3B+,我希望能够通过CLI通过互联网向朋友和家人发送大型文件。 为此,我使用以下方法: https://github.com/justbeamit/beam/blob/master/beam
但是,当我想上传一个大于~1.5Gb的文件时(,据我估计),我会收到一个错误提示:
OverflowError
long int too large to convert to int
经过简短的调查,我可以看到它来自第288行,在该行中设置了进度条的最大值,采用这种方法:
def transfer(token, filePaths):
print("recipient has connected! starting transfer...")
uploadUrl = ACTIVE_BACKEND + "/upload"
try:
index = 0
ProgressBar.totalNumberOfFiles = len(filePaths)
for filePath in filePaths:
# make the console look pretty
sys.stdout.write("\n")
print(" " + filePath)
# the callback function invoked by the monitor
def updateProgress(monitor):
theProgressBar.update(monitor.bytes_read)
# setup the multi-part encoder & its monitor
fileMPE = getMultipartEncoder(filePath)
monitor = MultipartEncoderMonitor(fileMPE, updateProgress)
# setup the progress bar
ProgressBar.fileNumber = index + 1 # to avoid showing (0 of 3)
# since the progress bar will be updated by the multi-part encoder, we can't set 'maxval'
# to be the file's size since the encoder adds extra bytes to account for the header
theProgressBar = ProgressBar(
maxval = len(fileMPE),
widgets = WIDGETS,
)
theProgressBar.start()
urlParams = {
"type": "CLI",
"token": token,
"index": index
}
requests.post(
uploadUrl,
data=monitor,
params=urlParams,
headers={'Content-Type': monitor.content_type}
)
theProgressBar.finish()
index += 1
# end for loop
except Exception as e:
print(e.__class__.__name__)
print(e)
exit()
finally:
sys.stdout.write("\n")
有人能帮我吗?这很烦人,因为没有进度条,一切都会很好地工作。 我试图对这一行进行注释,但是错误转移到了其他地方,在第300行(requests.post)
我的信息:
python——版本=>;Python 2.7.13
拉斯宾版本=>;PRETTY_NAME=“Raspbian GNU/Linux 9(扩展)”
您确定组合文件大小不大于4 GB吗?我认为您正在使用Python "bug",因为您的Pi可能运行32位。}的{a2}中提到。
这个问题也在{
要解决此问题,您需要更新版本的请求工具带(我使用
0.6.0
成功测试),并对beam本身进行一个小改动:相关问题 更多 >
编程相关推荐