Yes you can and you SHOULD!
If you have a server, it needs to have UPS for many reasons. (UPS - uninterruptible power supply)
I have Qnap server also, that has its own UPS by APC; I like APC brand very much for their quality and reliability!
Server is much more sensitive to power than a regular computer, in my opinion.
I would not put the server into a closet, because the server needs a good airflow and cool air. The closet, in most cases, has no air went and can overheat very fast!
If you need to use the closet, make sure you provide airflow and do not put the server close to the ceiling, but much lower, where the temperature is cooler. If you do not use A/C in your room, you should equip your server with temperature sensor, that would shut down the server, with a signal, not shutting the power off, so your server doesn't overheat!
Good luck.