We know that viruses and other threats can propagate through mail etc.But when any resource is shared,it is uploaded to the server and then shared.This means that the server does not take the responsibility of cleaning the uploaded files of viruses.Then how does it ensure self defense and secure the resources present on it and various services running on it?
The server should do validation on the user submitted file. E.g. If you allow the user to upload an image file for their profile picture, you should make sure that the file is a JPEG or PNG file and not an EXE file.
If you are running a file sharing service and allow all types of files to be uploaded. Even if a malicious file to be uploaded, it will not infect your system as long as you do not execute it. For added security, set the executable flag to be off so that it cannot be executed through any means.