Can't upload image attachments (2.4.0rc3, rc4)


#1

Since upgrading from 2.3.3 to 2.4.0rc3 it is no longer possible to upload JPG or PNG image attachments on my instance. After selecting the image file an error pops up in the bottom left corner stating “Oops! An unexpected error occurred.” There is no file-upload progress bar displayed and the error message appears as soon the file selection dialog is OK’d.

However, other media types work fine – I can attach GIF and video files without a problem. I can also attach photos via apps (Tusky, Mastalab) without any problem.

I have tried several browsers (Chrome, Firefox, Edge) on different computers in case it was some browser or caching problem. I also tried all this with a new dummy account on my instance. No browser will let me attach an image to a toot for any user account I have tried.

The server (nginx 1.10.3) config has not changed since the upgrade and all folder permissions (in public/system) also seem to be correct. The server is fine for storage space (42 GB free) and memory (60% of 3GB used, generally).

I have also tried upgrading to 2.4.0rc4 which was release last night but the problem is still there.

If anyone has any ideas on how to fix this or at least begin troubleshooting they would be very much appreciated!

Cheers,
Dave


#2

It might be a JavaScript error, check the web inspector log for specific error messages. Specifically it’s probably about in-browser resizing of overly large JPG/PNG images before upload. Were the images larger than 1280px in any dimension? Surprised that seemingly all browsers are affected for you, because I would expect it to be a browser-specific error since that code definitely does work for me on Firefox.


#3

Ah-ha! Excellent advice, thank you!

There was indeed an error noted in the inspector when I tried the file upload:

Refused to load the image blob:https://scicomm.xyz/ ... [etc] ... because it violates the following Content Security Policy directive: "img-src 'self' data:"

I just needed to add ‘blob:’ to that part of the CSP in my nginx site configuration, i.e. img-src ‘self’ data: blob:; to get images to upload again. I also had to add blob: to connect-src to allow larger images to load.

I shall now go ahead and use the facility to upload some quokkas to the fediverse.

Cheers,
Dave