fausecteam / ctf-gameserver

FAUST Gameserver for attack-defense CTFs
https://ctf-gameserver.org
ISC License
64 stars 27 forks source link

Img uploads #47

Closed maltek closed 5 years ago

maltek commented 6 years ago

I still need to test this, but it should fix #19.

We should also catch PIL/Pillow exception at opening (it will throw OSError for non-imge files)

Django should already be doing that for us [1]. I've also changed the code to make use of the Image instance it provides us with (but I'll still need to test that this actually works, for now I've only read the Django code to figure out which object stores the image instance).

How would you generate filenames? Adding a database field ... AFAICT there's already a database field (the generated file name is only used if that name is available, otherwise a random file name is used instead [2]). Using the team id for the default file name still seems like a good idea though.

1: https://docs.djangoproject.com/en/2.0/ref/forms/fields/#django.forms.ImageField 2: https://github.com/django/django/blob/64b74804c537b12d4cca64f7cb529c0478b4c4d9/django/core/files/storage.py#L279