refactored file uploads
Merge pull request #1680 from mikspark/refactor-upload

Refactor upload