code improvements, design of upload file and use config to determine media path