hiroi-sora / Umi-OCR_v2

结束和新的开始
MIT License
915 stars 69 forks source link

http模式 上传base64文件大小问题 #49

Closed SuperMMORPG closed 6 months ago

SuperMMORPG commented 8 months ago

http服务 上传文件的时候,如果转过来的图片base64信息比较大。 web服务器会返回 413 Request Entity Too Large 问题。

SuperMMORPG commented 8 months ago
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
    <head>
        <title>Error: 413 Request Entity Too Large</title>
        <style type="text/css">
          html {background-color: #eee; font-family: sans;}
          body {background-color: #fff; border: 1px solid #ddd;
                padding: 15px; margin: 15px;}
          pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}
        </style>
    </head>
    <body>
        <h1>Error: 413 Request Entity Too Large</h1>
        <p>Sorry, the requested URL <tt>&#039;http://127.0.0.1:1224/api/ocr&#039;</tt>
           caused an error:</p>
        <pre>Request to large</pre>
    </body>
</html>
hiroi-sora commented 8 months ago

确实,我没考虑到请求大小的问题。

你可以通过下述操作调整请求大小:

  1. 打开文件

    UmiOCR-data\py_src\server\bottle.py
  2. 第1131行左右,原本是:

    #: Maximum size of memory buffer for :attr:`body` in bytes.
    MEMFILE_MAX = 102400

    将它改为:

    #: Maximum size of memory buffer for :attr:`body` in bytes.
    MEMFILE_MAX = 10485760

    这将设置单次请求上限为10MB。你可以改为别的值。

请测试该方法是否有效。我将在下次更新修复此问题。

参考: https://www.osgeo.cn/bottle/api.html https://stackoverflow.com/questions/16865997/python-bottle-module-causes-error-413-request-entity-too-large

SuperMMORPG commented 8 months ago

设置后, 方法可行。 感谢!