如何仅向经过身份验证的用户显示流媒体视频?
我正在 CakePHP 中创建一个 Web 应用程序,让用户注册并上传他们的照片和 flv 视频,然后用户自己和他列表中的朋友就可以查看这些照片和 flv 视频。现在,对于图像部分,上传的文件将转到 htaccess 受保护的文件夹,然后经过身份验证的用户通过 php 脚本读取该文件夹。但是,我也想通过流媒体视频实现同样的目标。
那么,是否可以通过 php 流式传输视频,并且使用 htaccess 来保护您的用户文件是否安全?如果没有,有人可以指导我以正确的方式处理这种情况吗?
提前致谢。
I am creating a web application in CakePHP that lets a user register and upload their photos and flv videos that can be then viewed by the user himself and the friends in his list. Now, for the images part, the uploaded files are going to a htaccess protected folder which are then being read through a php script by the authenticated users. But, I want to achieve the same with streaming videos as well.
So, is it possible to stream videos through php and is it safe to use htaccess to protect your user files? If not, can someone guide me through a proper way of handling such situations?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
aadravid,
阅读有关 htaccess 解决方案的信息,我想知道是否 AUTH/基于 ACL 的方法不会更好。进入这个领域的最简单方法是acl/auth 教程< /a>.
仅使用 CakePHP 功能来实现它可以消除看起来奇怪的 Apache 身份验证弹出窗口。
编辑0:
也许安全组件适合您?
编辑1:
进一步思考和讲授,您可能:
对于组访问,您可以在此步骤中施展一些魔法。
优点(如果该解决方案有效,你就是我的小白鼠:-)):
弱点:
- 不幸的是,这不是一个一键蛋糕php就会做的解决方案
明确用于创建这篇文章的来源:
我花了很长时间才想出这个,所以每个人都可以随意讨论你的想法(或投赞成票:-))
编辑2:
wrksx 是 cakePHP 社区的活跃贡献者,他给了我尝试
MediaView
的建议*嗅探*
编辑3:
另一个贡献者, voidet,指出
MediaView
的分块 - 以及您使用的通过 PHP 提供静态文件的方法 - 会占用 CPU。您可以安装x-sendfile 作为 apache 模块或诉诸我的解决方案,如果性能影响太大。
维护 htaccess 文件可能具有挑战性。
aadravid,
reading about the htaccess solution, i wonder if a AUTH/ACL based approach would not be better. The easiest way to enter this realm is the acl/auth tutorial.
Implementing it exclusively with the CakePHP features would get rid of the strangely looking Apache authentication popup.
Edit0:
Maybe the Security Component is for you?
Edit1:
Giving it further thought and lecture, you maybe:
For group access, you could do some magic in this step.
Strong points (if the solution works, you are my guinea pig :-)):
Weak points:
- Unfortunatly not a one-call-cakephp-will-do-it solution
Sources explicitly used to create this post:
It took me quite a time to come up with this, so everybody feel free to discuss your ideas (or upvote :-))
Edit2:
wrksx, an active contributor in the cakePHP community, gave me the tip to try
MediaView
*sniff*
Edit3:
Another contributor, voidet, pointed out that
MediaView
s chunking - and by the way your used method of serving static files through PHP - hits the CPU. You can installx-sendfile as apache module or resort to my solution, if the performance hit is too big.
Maintaining the htaccess files could be challenging.