mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
FIX: Better 0 file size detection and logging (#16116)
When creating files with create-multipart, if the file size was somehow zero we were showing a very unhelpful error message to the user. Now we show a nicer message, and proactively don't call the API if we know the file size is 0 bytes in JS, along with extra console logging to help with debugging.
This commit is contained in:
parent
5f5acfa064
commit
7af01d88d2
7 changed files with 37 additions and 4 deletions
|
@ -200,6 +200,10 @@ class UploadsController < ApplicationController
|
|||
end
|
||||
|
||||
def validate_file_size(file_name:, file_size:)
|
||||
if file_size.zero?
|
||||
raise ExternalUploadValidationError.new(I18n.t("upload.size_zero_failure"))
|
||||
end
|
||||
|
||||
if file_size_too_big?(file_name, file_size)
|
||||
raise ExternalUploadValidationError.new(
|
||||
I18n.t(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue