(Bug 4715) Generate file ID after upload

Merges the generate id and upload step
(Bug 5137) Pass in status code to api_error