mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Show gif upload size limit error straight away (#21633)
When uploading images via direct to S3 upload, we were assuming that we could not pre-emptively check the file size because the client may do preprocessing to reduce the size, and UploadCreator could also further reduce the size. This, however, is not true of gifs, so we would have an issue where you upload a gif > the max_image_size_kb setting and had to wait until the upload completed for this error to show. Now, instead, when we direct upload gifs to S3, we check the size straight away and present a file size error to the user rather than making them wait. This will increase meme efficiency by approximately 1000%.
This commit is contained in:
@@ -853,6 +853,16 @@ RSpec.describe UploadsController do
|
||||
)
|
||||
end
|
||||
|
||||
it "returns 422 when the file is an gif and it's too big, since gifs cannot be resized on client" do
|
||||
SiteSetting.max_image_size_kb = 1024
|
||||
post "/uploads/create-multipart.json",
|
||||
**{ params: { file_name: "test.gif", file_size: 9_999_999, upload_type: "composer" } }
|
||||
expect(response.status).to eq(422)
|
||||
expect(response.body).to include(
|
||||
I18n.t("upload.images.too_large_humanized", max_size: "1 MB"),
|
||||
)
|
||||
end
|
||||
|
||||
it "returns a sensible error if the file size is 0 bytes" do
|
||||
SiteSetting.authorized_extensions = "*"
|
||||
stub_create_multipart_request
|
||||
|
||||
Reference in New Issue
Block a user