经过多年在这里寻找答案,终于到了我提出第一个问题的时候了。
在家里运行像迷你服务器一样的 RPI3B+,我希望能够通过 CLI 通过 Internet 将大文件发送给朋友和家人。为此,我正在使用这个: 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 --version => Python 2.7.13
Raspbian 版本=> PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"