fwrite(binaryarray, sizeof(binaryarray), 1, fTTY); // ??
Data is Data. Problem is most seem to have skipped/avoided the whole "how is data represented in memory and files" topic.
Most probably package the data in some object form, providing size, address and other details.
Pushing a file as it's inherent data content in a way you can reconstruct it, X/Y-Modem protocols have been used for serial links, the popularity here coming from it being self pacing, and retry/recovery from data loss/corruption issues.
Pulling from a file server? HTTP GET tells you in the response header how big the subsequent blob of data is. Strong benefit here is that you don't need to engineer both ends of the connection, its a ubiquitous standard, frequently with modem side support, but even at a socket level its not very complicated.
If ASCII is easier to manage the .BIN could be formed as .HEX file sentences/lines, the resulting data transfer would look about 2.5x bigger in overall volume. You'd likely need some kind of flow control, as the data is likely to arrive faster than the write to flash can work.
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..