Upload media only to DB

Yes, out of the box WordPress stores images and other uploads only as files.

Although it could be, theoretically, possible to change this behavior by tapping inton wp_handle_upload() or _wp_handle_upload() and related functions, I think it would be too complex and unreliable. Besides,I think it wouldn’t be a good idea for performance reasons in case with too many images (then again, I am not a DB specialist)

And just for good measure, if you want to change uploads folder location, you can do it by defining the UPLOADS constant in wp-config.php file:

define( 'UPLOADS', 'new-folder-for-uploads' );

Edit 1

Adding my response to the Peter Badida comment about :

I can’t tell for sure, but I think you could experiment with the filesystem_method_file filter on the WP_Filesystem function, located at line 1867 of /wp-admin/includes/file.php and add your own abstractions.

Bear in mind that plugins and themes will probably use functions, actions and filters that rely on a disk based filesystem. So you will need to keep a lot of the current filesystem for compatibility and make things more complex than needed. Great intelectual and WP developing challenge, but from a pragmatic perspective, I would stick to the default filesystems.

Edit 2 (from comment)

WordPress is built in a way that you can override or extend a lot of its functionality mostly by using filters and actions hooks. Stick to them and you will have far fewer headaches and imcompatibility issues.

Here you can find all or most of the hooks. Also, you might want to search for apply_filter and do_actionstrings on WordPress Core codebase.