Unverified Commit 668a9e88 authored by Lincoln Nogueira's avatar Lincoln Nogueira Committed by GitHub

fix: File size exceeds allowed limit of 0 MiB (#1664)

fix: File size exceeds allowed limit of 0 MiB

This could happen in databases without "max-upload-size-mib" setting.

Now, both the front-end and the back-end will start with a default
limit of 32 MiB, even if the key is absent.

It is still possible to disable uploads by setting the value to 0.
parent cd2bdab6
...@@ -70,7 +70,8 @@ func (s *Server) registerResourceRoutes(g *echo.Group) { ...@@ -70,7 +70,8 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session") return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")
} }
maxUploadSetting := s.Store.GetSystemSettingValueOrDefault(&ctx, api.SystemSettingMaxUploadSizeMiBName, "0") // This is the backend default max upload size limit.
maxUploadSetting := s.Store.GetSystemSettingValueOrDefault(&ctx, api.SystemSettingMaxUploadSizeMiBName, "32")
var settingMaxUploadSizeBytes int var settingMaxUploadSizeBytes int
if settingMaxUploadSizeMiB, err := strconv.Atoi(maxUploadSetting); err == nil { if settingMaxUploadSizeMiB, err := strconv.Atoi(maxUploadSetting); err == nil {
settingMaxUploadSizeBytes = settingMaxUploadSizeMiB * MebiByte settingMaxUploadSizeBytes = settingMaxUploadSizeMiB * MebiByte
......
...@@ -44,7 +44,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) { ...@@ -44,7 +44,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
AllowSignUp: false, AllowSignUp: false,
IgnoreUpgrade: false, IgnoreUpgrade: false,
DisablePublicMemos: false, DisablePublicMemos: false,
MaxUploadSizeMiB: 32, MaxUploadSizeMiB: 32, // this is the frontend default value
AdditionalStyle: "", AdditionalStyle: "",
AdditionalScript: "", AdditionalScript: "",
CustomizedProfile: api.CustomizedProfile{ CustomizedProfile: api.CustomizedProfile{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment