Monday, January 18, 2016

Creating a file in AEM via CURL

I've just come across a requirement to create a status.html file that's purely used as a health check file. to move a stack in or out of the load-balance pool. If the file exists (returns a 200) then the node is in the pool; if it 404's then it's out of the pool.

Searching around I couldn't find much until I came across this post on the Adobe Forums: How do i create a nt:file using Curl? and that gave me the correct command to use.
echo "OK" | curl -u admin:admin -T - http://localhost:4502/etc/hc/status.html
What we're doing here is creating the contents of the file using echo and piping this into the "-T -" as the file contents. Pretty nifty!