Simplify database connection management.

Bluebird has support for disposers built-in.
Fix submission uploads without custom thumbnails.

This saves thumbnail cropping for later and also moves the handling of
empty uploads into media.upload() so they don’t fail identification.