Rework file upload for #360 and #361
Merge pull request #400 from cpoulain/master

Rework file upload for #360 and #361