Search code examples
javascriptphpangularjslaravelhtml5-audio

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.

I use laravel v5.4 framework for backnd and anguler v5.5 for frontend and mp3 music player I use html5.

My application work greatly. In UI no body can't find any mp3 url, But

When I go browser developer tools and Storage inspector -> Local storage I see my full mp3 url there.

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.

Anybody have any idea?


Solution

  • 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. This method accepts a path and a DateTime instance specifying when the URL should expire:

    $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.