I am using an asynchronous webservice which send me back a Job ID. The full response is then send by the webservice as an XML file (jobId.xml) to my server using a PUT request.
After issuing the request to the webservice and getting the jobID, I
would like to know what would be the best (most efficient) way to wait
until the file is created into the PUT directory of my server?
I am thinking of a loop of file_exist() with a usleep() between each execution and with a timeout.
But I am sure that there is a better way.
Something like a listener…
The file can take less than a second to more than 1 minute to arrive.
Thanks!
You could use
inotifyto watch for file creations in some directory.Alternatively you could modify your PUT handler to notify your script. For example, you could create a named pipe, read from it (blocking), and modify your PUT handler to write on the pipe one it has written the file