I'm also facing actually multiple issues and getting no support. The issue are in the firmware of the Photon and I cannot do anything and I'm stuck there...
I understand the intent, but you should use contentData[512] = ‘\0’; instead. By using 513, you are actually setting the contents of whatever is in memory AFTER your array. This next byte could be an unused memory location or it could be a loop variable. You don’t know. Bad things can happen and be almost impossible to track down.
For example, looking at your code, it might be your “dataPos” variable. You declare it after contentData, so it might be located in memory just after your array. Not …