http api: use file.write()