I''d like to monitor a folder and when someone drops a file in there I can take the files name and add it to a database. My dream is to have a folder always being watched. and if someone drops a file or folders with files into that watched folder, I take the filename(s) and insert them into a db and if the files are in folder I use the folder name(s) as tags for that file. make sense? can it be done? I''m still real new at this and have big dreams, eh? i have''t seen any tutorials one how to do this in ROR, I''ve seen .Net and coldfusion. I saw this but not sure how to use it. http://www.jhorman.org/FileSystemWatcher/index.html thanks John Ivanoff
> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of John Ivanoff > Sent: Tuesday, August 15, 2006 9:02 AM > To: rails@lists.rubyonrails.org > Subject: [Rails] FileSystemWatcher - has any one done this? > > > I''d like to monitor a folder and when someone drops a file in > there I can take the files name and add it to a database. > > My dream is to have a folder always being watched. and if > someone drops a file or folders with files into that watched > folder, I take the filename(s) and insert them into a db and > if the files are in folder I use the folder name(s) as tags > for that file. > > make sense? can it be done? I''m still real new at this and > have big dreams, eh? i have''t seen any tutorials one how to > do this in ROR, I''ve seen .Net and coldfusion.If Rails provides this functionality I''m not aware of it. Some platforms provide vendor-specific solutions (e.g. win32-changejournal for Windows, ruby-inotify for Linux). If you want a platform neutral solution you''ll just have to setup some kind of polling mechanism where you check the contents of a directory every X seconds and look for differences manually. If .NET and ColdFusion provide this functionality I''d love to know how. Through the webserver itself perhaps? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
On 8/15/06, John Ivanoff <john.ivanoff@gmail.com> wrote:> I''d like to monitor a folder and when someone drops a file in there I > can take the files name and add it to a database.This is OS dependent - I''ve done it under linux using inotify, with a daemon monitoring the folder and calling an "add_from_inotify" class method in my model (via script/runner). Works very nicely. The code is quite trivial; I could probably get permission to post it if you''re interested. martin
I''m on a windows platform. coldfusion has event gateways in their enterprise ed, you can use them in the developer mode though. they have some cool examples http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00001649.htm look at the DirectoryWatcherGateway I have found it stops running if I put more that 50 files into it. I have a working example if you''re only doing a few files/folders. Since we''re buiding something new the users want to drop their folders in here. think of takeing your "my documents'' folder and having to move it online. that would take forever. this way I can drop and forget and then add indivudual files as needed. (i''m rambling) for dot net I found these searches http://www.google.com/search?q=c%23+directory+watch&hl=en&lrhttp://www.google.com/search?q=.NET+class+FileSystemWatcher&hl=en&lr I liked this but I haven''t had to get into .net yet. this one can run as a service. http://www.codeproject.com/csharp/FileWatcherWinServiceCSha.asp On 8/15/06, Martin DeMello <martindemello@gmail.com> wrote:> On 8/15/06, John Ivanoff <john.ivanoff@gmail.com> wrote: > > I''d like to monitor a folder and when someone drops a file in there I > > can take the files name and add it to a database. > > This is OS dependent - I''ve done it under linux using inotify, with a > daemon monitoring the folder and calling an "add_from_inotify" class > method in my model (via script/runner). Works very nicely. The code is > quite trivial; I could probably get permission to post it if you''re > interested. > > martin > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
sounds like anouther use for backgroundrb... 2006/8/15, John Ivanoff <john.ivanoff@gmail.com>:> > I''d like to monitor a folder and when someone drops a file in there I > can take the files name and add it to a database. > > My dream is to have a folder always being watched. and if someone > drops a file or folders with files into that watched folder, I take > the filename(s) and insert them into a db and if the files are in > folder I use the folder name(s) as tags for that file. > > make sense? can it be done? I''m still real new at this and have big > dreams, eh? > i have''t seen any tutorials one how to do this in ROR, I''ve seen .Net > and coldfusion. > > I saw this but not sure how to use it. > http://www.jhorman.org/FileSystemWatcher/index.html > > thanks > John Ivanoff > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Michael Siebert <info@siebert-wd.de> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060815/99b300a8/attachment.html
FreeBSD has kqueue, and Windows has a built-in feature as well. I''ve done several polling routines using the opendir() syscall, and much prefer kqueue. Webservers have well-written internal methods, but I don''t know if they expose an API. But the question remains "how to do it in a platform-independant way from Ruby". Polling will work, but if you want low-latency notification, you''ll burn cpu. Don''t forget all the edge cases, like multiple files appearing in a single polling cycle, files deleted by external means (ftp), partial files (in-transit ftp partials can be avoided by regex matching on a suffix to which a file is renamed only upon completion), files edited or modified in-place, files opened by a program (eg editor) that crashes, system crashes and reboots, big files filling the disk partition, file processing (including exceptions) blocking new file notification, etc. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060815/0b89d09e/attachment.html
> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Randy Parker> Sent: Tuesday, August 15, 2006 10:19 AM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] FileSystemWatcher - has any one done this? > > >FreeBSD has kqueue, and Windows has a built-in feature as well. I''vedone several polling routines using the opendir() syscall, and much prefer kqueue. Webservers have well-written internal methods, but I don''t know if they expose an API.> >But the question remains "how to do it in a platform-independant wayfrom Ruby". Polling will work, but if you want low-latency notification, you''ll burn cpu. There''s Ara Howard''s ''dirwatch'' package on the RAA: http://raa.ruby-lang.org/project/dirwatch/ I''ve never used it myself, however. HTH, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.