in content=function(file) {
the file will be provided by the shiny runtime; it will be a random file location in temporary storage that can be written to.
the code in this content handler must write a file with the file name for the handler to work.
The final name of the file is decided by filename=function() { and in your case is test.xlsx and this would work if you produced a file and observed what the filename in the browser showed itself to be.
i.e. there is a renaming step, where the arbitrary file you gave gets the name you describe at the point of being deliverable.
Oh okay thank you for the explanation! That makes sense for this toy example.
I'm guessing I've found a case where that renaming step fails at the end in an Ubuntu Server, and not when running the app locally in Windows. On our hosted shiny app we get an error *.htm file wasn't available on site. Locally, in Windows, it runs fine. Unfortunately this is difficult to replicate due to not all cases running into this issue in Linux. So Linux isn't the only prerequisite to getting this error.
Currently we have a workaround by just overwriting the file argument in the content=function(file) part. I'll see if I can find a better replica of the error we're seeing.