authenticateAndPostToURL: make file parameter optional

This enables POST to be used for any request that changes database
state, so that we don't have to use GET for this.

Also use MIME tools to generate the document.
We end up with the file base64-encoded.
I don't know if this is necessary.
Trivial tweaks

Keep actionType as first parameter;
add a wait (my slow laptop was timing out).