This have constipation caused what I think is my first experience of piles? How should I treat it?

Fiber/water. Constipation and hemorrhoids can be treated by changing a diet to include lots of fiber (fruits and vegetables are best for this - pills/powders not as much) and at the same time markedly increasing water intake (not soda, not coffee). The goal is to have soft mushy stools a couple of times a day - so that straining is unnecessary over a period of a few months most people's hemorrhoids improve.