Write binary file in SPIFFS (ESP8266/32)

Hello, all!
I'm trying write binary file in SPIFFS, but I face with a problem. The SPIFFS.write have no "wb" mode and using POSIX style is reseting MCU.

This way is not working:

      FILE *ptr;
      byte bb[1];
      bb[0] = 0xD8;
      ptr = fopen("/teste.bin", "wb");
      fwrite(bb, 1, 1, ptr);

And using SPIFFS.write("/teste.bin", FILE_WRITE) makes a plain text file. Reading byte 2 and 3 I got D and 8, respectively.

Does anyone have a solution?

use w not wb and use write, not print

Wow! I thank you very much! It's working now!