I'm developing software to send and receive files.
The file is divided into small parts to be sent on the network. Initially I sent byte arrays directly, without headers or anything like that. But now I have seen that it is possible to send byte arrays through the JSON. The JSON now encodes the bytes in base64 and creates a text string. The problem is that this text string far exceeds the actual length of the bytes entered.
For example, a file of 200 mb size, encoded in base64, increases to a size of about 300 mb. Even if once reconverted to bytes the value returns to 200 mb, to send it, the extra 100 mb is a problem.
The class to be serialized :
[JsonProperty]
public long filePointer { get; set; }
[JsonProperty]
public byte[] fileData { get; set; }
The main code :
FilePart filePart = new FilePart {
filePointer = getFilePointer(),
fileData = getFileData()
};
JsonConvert.SerializeObject(filePart);
I would like to know if there is a way to optimize this length increment or if there are better ways to send byte arrays.