fix #10727, so raw file bean can create empty files

To test, try attachment normal files and empty ones to images or datasets or whatever and make sure they go without errors and after download arrive intact, the same as they went.

rebases #1076 and #1102