简体   繁体   English

如何保护 MP3 网址?

[英]How do I secure an MP3 url?

I am making a music website where I stream free music, but I don't want to user download the mp3 file form my serve.我正在制作一个音乐网站,我可以在其中播放免费音乐,但我不想让用户从我的服务中下载 mp3 文件。

I use laravel v5.4 framework for backnd and anguler v5.5 for frontend and mp3 music player I use html5.我使用 laravel v5.4 框架作为后端,anguler v5.5 用于前端和 mp3 音乐播放器我​​使用 html5。

My application work greatly.我的应用程序工作得很好。 In UI no body can't find any mp3 url, But在 UI 中,没有正文找不到任何 mp3 网址,但是

When I go browser developer tools and Storage inspector -> Local storage I see my full mp3 url there.当我使用浏览器开发人员工具和存储检查器 -> 本地存储时,我会在那里看到我的完整 mp3 网址。

I look at internet can find any soluton where I can hide the mp3 url or secure them where user can't find url or download directly mp3 from the url.我在互联网上可以找到任何可以隐藏 mp3 url 的解决方案,或者在用户找不到 url 的地方保护它们,或者直接从 url 下载 mp3。

Anybody have any idea?有人有什么想法吗?

From the docs :文档

For files stored using the s3 or rackspace driver, you may create a temporary URL to a given file using the temporaryUrl method.对于使用存储的文件s3rackspace的驱动程序,您可以创建一个临时的URL使用给定文件temporaryUrl方法。 This method accepts a path and a DateTime instance specifying when the URL should expire:此方法接受一个路径和一个 DateTime 实例,指定 URL 何时到期:

$url = Storage::temporaryUrl(
    'file1.jpg', now()->addMinutes(5)
);

If you don't use one of these services to store files, you need to create temporary URLs manually.如果您不使用这些服务之一来存储文件,则需要手动创建临时 URL。

You can secure the tracks by setting up S3's Bucket Policy.您可以通过设置 S3 的存储桶策略来保护轨道。

Example:示例:

{
    "Id": "Policy10197062190400",
    "Version": "2012-10-17",
    "Statement": [
       {
            "Sid": "Stmt1597062199047",
            "Action": [
                "s3:GetObject"
            ],
            "Effect": "Deny",
            "Resource": "arn:aws:s3:::My-project/*",
            "Condition": {
                "StringNotLike": {
                    "aws:Referer": "http:MyDomain/"
                }
            },
            "Principal": "*"
        }
    ]
}

You can restrict the music to be served only for MyDomain .您可以限制只为MyDomain提供音乐。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM