ESP8266 Switching firmware on the fly Can you help me out to understand if this is possible with ESP8266 / 32 ?

I have a main binary that i upload to the chip, let's call it A - that's done from arduino.

A starts to work, but communicates every couple of minutes with central server polling for a task.

If there is a task - let's call it B 

A downloads it and stores it on SPIFFS.

Now what should happen is that A uploads it, reboots and B starts to work.

When B finishes it loads up again A and the circle closes - this process goes on forever.

Questions:

1) Is it possible that a stored on SPIFFS binary file can be uploaded to the chip? Like OTA does via www.

2) Can i somehow store A onto the SPIFFS, so that when B finishes i reupload A ?

Thanks for any input into this
The esp8266 Arduino package has 3 libraries for firmware update. 


ArduinoOTA for upload from Arduino IDE
ESP8266HTTPUpdateServer for upload with web browser
ESP8266httpUpdate library to check a web server for new version of the
firmware