Best answer

Trigger When New/Changed Files Added to a Directory on a Web Server

  • 25 October 2019
  • 7 replies
  • 5631 views

Userlevel 4
Badge

I have been trying to find a way to trigger a zap when a file is added or changed on a server.

I know this is easy to do using a cloud service like Google Drive, but in this case, a cloud service is not an option. The files can only exist on the server hosted by our web hosting service.

So far, I have had no luck in finding a solution, but am probably overlooking something obvious.

Any suggestions?




icon

Best answer by RonW 30 October 2019, 22:56

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

7 replies

Userlevel 5
Badge +3

do you have access to server? i'd put a cron script on server looking for new/modified files, then send a post to a zapier webhook trigger when something added/updated.


Userlevel 4
Badge

I did play around with this for a bit, but due to my own limited knowledge about Cron and Linux command line, I did not get very far with it.

The hosting service also seems to limit output from the script to just text in an email message. The problem with this was that there may be one or more changed files in the email message, which then turns into a bit of a parsing process to extract out just the file names and remove duplicates. It just seemed to be getting far more complicated than I would have expected it to be.


Userlevel 7
Badge +10

@RonW since you control the output of the email you could use 10 character sequence for the pattern search, and have parser grab everything in between then use Zapier formatter steps to split out the file names

ex email:

here are the new files:

@&#^$*&@^%

filename1.txt

filename2.bat

@&#^$*&@^%

Then you

mailparser to grab everything between the @&#^$*&@^% and you can then use formatter steps to break up the filenames.



Userlevel 5

Many webhosts are running some flavor of Linux, so it seems likely that yours is. If so, then perhaps the inotifywait command is available to you (or could perhaps be installed for you).

Basically, it monitors a given directory tree for changes and then runs a command of your choosing. You could set it up to post to a Zapier webhook, for example.

Here's the Linux man page entry for inotifywait.

If you have SSH access to your web host, you can try running it to see it it's installed. Let me know if you'd like more detail!





Userlevel 4
Badge

Thank you very much for the suggestions!

The biggest problem is my own lack of experience using Linux commands or scripts. Just using the web-based Cron interface provided by the hosting service, it does not appear that I have a lot of options on how to control the content of the email message.

I am pretty sure I can access the server via SSH and can probably run all of the standard Linux commands or scripts. I just need to do some learnin'. I just thought that there might be a "tick the box" type of solution that I was overlooking.

In the meantime, I needed a quick solution to solve a business problem, so I cobbled up a workaround for now and will revisit this a bit later.



Userlevel 7
Badge +10

Thanks for the update @RonW For anyone else looking to solve this problem in the future do you mind sharing what cobbled workaround you put in place? Also, when you get back to this let us know how we can help.

(I do recommend calling your server provider and seeing if they can help you with the Linux commands)


Userlevel 4
Badge

We use Google Drive Stream to provide local Windows access to the files on our Google drive. So I set up a scheduled Windows batch process that uses WinSCP to copy any newly created files on our hosted server to a local folder on my computer that is synced to our Google Drive. Once on the file is synced to Google Drive, I can then use Zapier's Google Drive - Updated File app to watch for and process any newly added files.

Not a very elegant solution, but works and is good enough until I can come up with something better.