Problem downloading audio . wav Laravel 5.2

Asked

Viewed 86 times

0

When I play the audio . mp3 it works normally, but when it is an audio . wav it even goes down, but when I listen to it from a runtime error. If I go in the directory where this audio is. wav, I can hear it normally, the problem is even only when low. Code that makes the download

$filename = $arquivo;
$path = storage_path('app/ligacoes_snep/'.$filename);

return Response::make(file_get_contents($path), 200, [
                'Content-Type' => 'audio/wav',
                'Content-Disposition' => 'inline; filename="'.$filename.'"']);

No Content-Type já tried audio/vnd.wave, audio/wav, audio/wave, audio/x-wav.

  • Note that the content-type will not actually affect the execution, maybe the audio when you uploaded has been damaged.

  • But then it would be trouble also when I went to hear it right in the directory

  • Maybe the path you’ve gone through is wrong, it could be a milkshake or a minuscule in the file name.

  • Anyway try it this way: return Response::make(file_get_contents($path), 200, [
 'Content-Type' => 'audio/wav',
 'Content-Transfer-Encoding: binary',
 'Content-Disposition' => 'inline; filename="'.$filename.'"']);

  • I capture this link on another server and pass to the one of my system, all the time I use the same name variable.. and if it were the cases of . mp3 would give error tbm

  • There is no way to affirm anything, it may not even have to do with the format, it may just be your confusion. You can’t know, anyway content-type does not influence, the problem must be something else.

  • unsuccessful....

  • Isn’t some letter wrong? Please give more details if it’s not difficult to help.

  • to kill this doubt, I went there on the server where I took the links and took a fixed name and happened the same problem :(

  • Fixed? Refers to opening . wav directly via URL (http), without Windows? If it is, it must be an upload error via FTP. Luiz tries this https://answall.com/a/226669/3635

  • No no, when I say fixed is that in the filename I passed a name of a direct link from there, went on the server gave Ctrl+c and pasted instead of filename. Another thing, the links are in . WAV and not .wav. Could be something with that?

  • yes, uppercase and minuscule letter as I said in the first comment can be a problem, because if you put in the URL something like foo.wav, but the file name is Foo.Wav will not open on Linux servers (most websites are linux)

  • I pass the name as it comes, when I search on the other server, I also use . WAV and when I download tbm I use . WAV, my question about . Larger WAV is that in another part of my system I save links . wav and I have no problem downloading, but it is . wav and not .WAV. Tendesse

Show 8 more comments

2 answers

0

According to the documentation of the Laravel (documentation of 5.5, but compatible with 5.2)

you better use it:

Return Response()->download($pathToFile);

Return Response()->download($pathToFile, $name, $headers);

Return Response()->download($pathToFile)->deleteFileAfterSend(true);

Or else the

Return Response()->file($pathToFile);

0


Solved. My problem was not with the file extension, but rather a code I was running before the download

SSH::into('intranet')->run("rm -/var/www/html/intranet/storage/app/ligacoes_snep/", function($line){
          echo $line;
});

Thank you for your attention..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.