refactoring upload media