I am qute new web developer and I am facing a problem with uploading files to Azure file storage. From Angular I am sending a files into Flask backend and from there it is uploaded to Azure. My application is able to transfer small files but with bigger ones like couple of MB I am receiving following error.
error: "<html>rn<head><title>413 Request Entity Too Large</title></head>rn<body>rn<center><h1>413 Request Entity Too Large</h1></center>rn<hr><center>nginx</center>rn</body>rn</html>rn"
During my resarches I have found that it can be the problem with IIS. So I modified my web.config file to following
<?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>
But unfortunately it doesn’t help me. The strange thing is that I am not using nginx but in the error message there is <center>nginx</center>
and I have no idea why nginx is mentioned there.
I have also found that there is something like HTTP binding but I am not sure which I have and I don’t how to check it. Does someone have any idea what can be wrong with my application? Thanks in advance
2
Answers
In the app nginx is not used but it is used in kubernetess ingress and there was a need to change the upload_max_filesize setting to bigger value. Default was 1MB
To resolve this issue, your Angular app can request a SAS token with write permission from the Flask backend and use this SAS token to upload a file to Azure storage directly by JavaScript v12 SDK for browser.
For how to generate a SAS token by python blob SDK, pls see my previous post. In this demo, you should set permission as
permission=BlobSasPermissions(write=True)
for uploading a file to the storage blob.This way could also greatly ease server IO pressure.
Let me know if it helps.