Attachment Type Restrictions in handler.py not working

I’d like to restrict Guest and Portal users to only upload certain types of files. From this frappe fix, it looks like I only need to change handler.py.

I’ve since removed unwanted types(excel) from the list in handler.py and restart the bench. However, portal users still can upload .xlsx files. Am I missing anything here?

hello, you can remove the following to block xlsx
“application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”

here is a reference for other files mimtypes
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

Thanks! The list actually only contains JPG, PNG, PDF. However all other types can still be uploaded.


ALLOWED_MIMETYPES = (
	"image/png",
	"image/jpeg",
	"application/pdf",
)

hello, maybe one reason is you need to do bench restart if self hosted or if you are using FrappeCloud go to bench > Versions > restart bench because ALLOWED_MIMETYPES is a global variable

1 Like

Self hosted v13 in development mode. Already did bench restart after modifying the list. I’m really confused why the changes has no effect. Not sure if there’s anything else I need to change?