0

经过多年在这里寻找答案,终于到了我提出第一个问题的时候了。


在家里运行像迷你服务器一样的 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)"

4

1 回答 1

0

您确定合并后的文件大小不大于 4 GB?我认为您遇到了这个 Python “错误”,因为您的 Pi 可能运行 32 位。的代码
中也 提到了这个问题。 要解决此问题,您需要更新版本的requests_toolbelt(我已成功测试)和对beam本身的小改动:requests_toolbelt
0.6.0

theProgressBar = ProgressBar(
    maxval = fileMPE.len,
    widgets = WIDGETS,
)
于 2020-05-06T16:04:47.587 回答