factorize the code between the various code path - fixed some logging stuff
Attach a file by drag & drop or click to upload