使用 PHP 检测远程 SMB 共享上的文件修改

发布于 2024-08-09 21:03:23 字数 219 浏览 5 评论 0原文

我正在编写一个 PHP 进程,该进程将在 Unix 计算机上运行,​​该进程需要监视远程 SMB 服务器并检测通过 FTP 上传到该服务器的新文件。我不太可能能够

它需要检测:

  1. 正在创建的新文件
  2. 文件上传完成
  3. 文件正在删除

如果它是 NFS 共享,我会尝试使用 FAM 来检测事件,但我看不到办法做任何同等的事情?

I'm writing a PHP process that will run on a Unix machine that will need to monitor a remote SMB server and detect new files that are being uploaded to that box via FTP. It's unlikely I'll be able to

It will need to detect:

  1. New files being created
  2. File upload completing
  3. Files being deleted

If it was an NFS share, I'd try using FAM to detect the events, but I can't see a way of doing anything equivalent?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吹泡泡o 2024-08-16 21:03:23

听起来不像我会在生产中使用的东西。但您可以尝试这样的操作:

  1. 使用 Samba 挂载 SMB 共享
    运行 PHP 的机器
    守护进程
  2. 使用 SPL
    递归迭代器迭代器与
    DirectoryIterator 来收集和
    维护所有文件的列表并
    共享驱动器上的文件
  3. 夹一次
    刷新一下文件夹列表并
    与当前状态进行比较,
    如果文件不再存在
    你知道它已被删除,如果
    有一个新文件将其放入
    排队并将其标记为“正在
    已上传”
  4. 在下一个“刷新运行”中
    检查排队的文件,它是文件
    文件上传大小没有改变
    可能已完成,如果文件大小
    更改后再次将其放入队列中
    并将其标记为“正在上传”

Doesn't sound like something I would use in production. But you could try something like this:

  1. mount the SMB share with Samba on
    the machine that is running a PHP
    daemon
  2. use SPL
    RecursiveIteratorIterator with
    DirectoryIterator to collect and
    maintain a list of all the files and
    folders on the shared drive
  3. once in
    a while refresh the folder list and
    compare it with the current state,
    if the file does not exist any more
    you know it has been deleted, if
    there is a new file put it in the
    queue and mark it as "being
    uploaded"
  4. in the next "refresh run"
    check the queued file, it the file
    size did not change the file upload
    probably completed, if the file size
    changed put it in the queue again
    and mark it as "being uploaded"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文