如何从 HTTP-auth 保护区获取图像?

发布于 2025-01-02 07:03:02 字数 502 浏览 3 评论 0原文

我有一个网络摄像头(D-LINK DCS-2130)和一个网站。相机没有“访客”选项(或者我没有找到它在哪里?),所以我需要授权我的网站显示来自相机的图像。显示图像的正确方法是什么?

我有 2 个想法:

  1. 创建 getImage.php,它将向相机发送 login+pass(cURL) 并 获取图像。在我网站的代码中,我将使用 src="getImage.php"
  2. 创建相同的 getImage.php,它将发送登录+pass(cURL),获取图像,将其本地存储到 / myCameraSnapshots/Image.jpg wait() 1 秒,然后获取新图像并在本地覆盖它。

第一种方式将对摄像机执行许多请求(1 个观看者 - 1 个请求),第二种方式将加载我服务器的 CPU,但不会干扰摄像机的授权。

我希望你可以说“你是个白痴!有一种简单的方法可以从受保护的文件夹中获取图像!只需执行...”;)

I have a web-camera(D-LINK DCS-2130) and a web-site. Camera haven't "guest" option(or I haven't found where is it?), that so I need to authorize my site to show image from cam. What is a correct way to display an image?

I have 2 ideas:

  1. Create getImage.php, which will send login+pass(cURL) to the camera and
    get the image. In my site's code I'll use src="getImage.php"
  2. Create same getImage.php, which will send login+pass(cURL), get the image, store it localy into /myCameraSnapshots/Image.jpg wait() 1 second, then get new image and overwrite it localy.

The first way will do many requests to the camera (1 viewer — 1 request), second will get load my server's CPU, but will not disturb camera's authorization.

I hope You can say "You're an idiot! There's a easy way to get image from protected folder! Just do..." ;)

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

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

发布评论

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

评论(2

水中月 2025-01-09 07:03:02

假设您在 getImage.php 中进行了正确的授权,则第二种方法(使用缓存)可能会更有效。

如果 getImage.php 使用 Content-Type 标头,则只需将 /myCameraSnapshots 置于 Web 服务器根目录之外(或将其限制为本地访问)仅),然后根据需要使用 readfile 在调用时转储内容。

根据相机上图像更改的频率,您还需要一种方法来使缓存的图像失效(可能通过删除它),这应该提示 getImage.php 再次请求它从相机。

Assuming that you are doing proper authorization in getImage.php, the second method (using a cache) will likely be more efficient.

If getImage.php uses a Content-Type header, then simply place /myCameraSnapshots out of the web server root (or restrict it to local access only), and then use readfile as needed to dump the contents when called.

Depending on how often the image(s) on the camera change, you will need a method to invalidate the cached image as well (perhaps by deleting it), which should prompt getImage.php to request it again from the camera.

执笏见 2025-01-09 07:03:02

我找到了该相机的访客密码(访客:访客),所以我的问题解决了,但无论如何每个人都应该阅读答案,在其中您可以找到您的问题的答案!

I've found guest's password for this camera (guest:guest), so my problem solved, but anyway everyone should to read answers, in them You can find answers to Your questions!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文