You just read the raw bytes of a file using QFile::readAll()
.
Q: Is there any way to know the name and extension of a QFile when its transformed into a QByteArray?
No. The file name and extension is not necessarily inserted in bytes of a file. It depends on the file format. For example you can make your custom file with a specific extension and put its name and extension at the begging of the bytes.
You can send the name and extension of the file manually before sending the raw bytes of the file. Before that you can send the length of name and extension and the number of bytes in file. This way you know how many bytes are related to name, extension and raw bytes.