Added mkdirp to create the folders if they do not exist
Refactored 'upload' method