The best solution I have found for this is using the pmount service.
I used the normal process to install it:
sudo apt-get install pmount
The only thing you need to worry about is if you already have regular directories in /media/pi with the same names as a USB drive. If you do, it will append a numeral as it mounts the drive.
For instance, if you have a directory named /media/pi/STICK and then you install a flash drive of the name STICK, you will find it has mounted it at /media/pi/STICK1
This can happen if you have had the stick installed but not properly ejected as it was removed, before installing pmount.
When that happened to me, my programs happily kept writing to my STICK but when I pulled it out and plugged it into another computer, it was empty. It was writing to the directory, and not to the device.
So I renamed the directory to /media/pi/temp, installed pmount, mounted STICK and copied the contents of temp to /media/pi/STICK
Then when I eject it, and verify on another computer, it is doing precisely what I intended.
autofs
, here is the doc: wiki.gentoo.org/wiki/AutoFS