classic-o / nova-media-library

Media Library for admin panel "Laravel Nova"
MIT License
157 stars 66 forks source link

Files through laravel should include 'Content-Length' and 'Content-Range' headers #49

Closed XGhozt closed 3 years ago

XGhozt commented 3 years ago

These headers should just always be here. In Chrome if the video is a media file then it causes problems (like being unable to skip around or not pre-loading the whole file). I would also suggest that we store the filesize in bytes instead of with the "kb" or "mb" text. I was able to add them manually since API::getPrivateFile() returns a \Illuminate\Http\Response class instance which solved my issue. This could just be baked in though.

In my case I was also using s3 with files as "private" so it was piping the file through laravel but I imagine it would have the same issue without it coming from s3.

Example if file size is 1234 bytes.

Content-Length: 1234
Accept-Ranges: bytes
Content-Range: bytes 0-1233/1234

Some examples of others with this problem (in general): https://stackoverflow.com/questions/45805177/chrome-cant-fast-forward-firefox-can-display-mp4-file-with-php https://stackoverflow.com/questions/61022041/unable-to-skip-audio-in-chrome https://stackoverflow.com/questions/10583931/cant-seek-html5-video-or-audio-in-chrome

classic-o commented 3 years ago

Fixed in 1.0.5