【发布时间】:2021-05-20 19:54:11
【问题描述】:
我是一名全新的 Web 开发人员,在将文件上传到 Azure 文件存储时遇到问题。从 Angular 我将文件发送到 Flask 后端,然后从那里上传到 Azure。我的应用程序能够传输小文件,但对于像几个 MB 这样的大文件,我收到以下错误。
error: "<html>\r\n<head><title>413 Request Entity Too Large</title></head>\r\n<body>\r\n<center><h1>413 Request Entity Too Large</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n"
在我的研究中,我发现这可能是 IIS 的问题。所以我将我的 web.config 文件修改为以下
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpRuntime maxRequestLength="500000" executionTimeout="120" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="500000000" />
</requestFiltering>
</security>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="./index.html" />
</rule>
</rules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".woff" mimeType="font/woff" />
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>
</system.webServer>
</configuration>
但不幸的是,它对我没有帮助。奇怪的是我没有使用 nginx,但在错误消息中有<center>nginx</center>,我不知道为什么在那里提到了 nginx。
我还发现有类似 HTTP 绑定的东西,但我不确定我有哪些,也不知道如何检查它。有人知道我的申请有什么问题吗?提前致谢
【问题讨论】:
-
FLask 后端可能正在使用 nginx,所以基本上最好的方法是 Stanley 建议您使用 SAS 令牌
-
如果我的帖子适合您,请您接受我的帖子吗? :)
-
但是要使用 SAS 令牌,我需要重建我的应用程序吗?因为我会请求一个 SAS 令牌并通过 Angular 前端进行整体更新。也许我只需要更改 nginx 设置?
-
我不太确定这个问题是否可以通过配置 Nginx 来解决(对于将大文件上传到存储,我认为您还需要修改您的 FLask 后端),但我相信我的解决方案会起作用正如我之前做过的那样,这是这种情况下推荐的方式,否则如果有很多用户上传文件,您的服务器将面临高IO和网络压力
-
好的,谢谢。如果推荐,我会尝试您的解决方案。我希望它会起作用。以前我认为最好在后端进行所有连接。我只是想知道我的 SAS 令牌是否在前端不可见?不是很危险吗?
标签: angular azure iis azure-blob-storage