Deduplicate file upload handling code

Signed-off-by: Sven Strickroth <email@cs-ware.de>