Page 3 of 3

Re: Setting Content_Type

Posted: Mon Sep 26, 2016 7:42 pm
by shortmort37
Same error (just a line further down with the "use" added).
Catchable fatal error: Argument 1 passed to Symfony\Component\HttpFoundation\BinaryFileResponse::prepare() must be an instance of Symfony\Component\HttpFoundation\Request, instance of phpbb\request\request given, called in /home/sportf5/public_html/59test/includes/functions_download.php on line 143 and defined in /home/sportf5/public_html/59test/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php on line 169

Re: Setting Content_Type

Posted: Mon Sep 26, 2016 7:45 pm
by kasimi
Post the whole if ($category == ATTACHMENT_CATEGORY_HTML5 ...) block.

Re: Setting Content_Type

Posted: Mon Sep 26, 2016 7:51 pm
by shortmort37
These are my mods - at the top,

Code: Select all

use Symfony\Component\HttpFoundation\BinaryFileResponse;
use phpbb\symfony_request;
Then:

Code: Select all

	if (!@file_exists($filename))
	{
		send_status_line(404, 'Not Found');
		trigger_error('ERROR_NO_ATTACHMENT');
	}
	// *** Adding HTML5 audio/video content!  Caveat Emptor
	if (($category == ATTACHMENT_CATEGORY_HTML5)
		&& ((strpos($attachment['mimetype'], 'video') !== 0)||(strpos($attachment['mimetype'], 'audio') !== 0)))
	{
		$response = new BinaryFileResponse($filename);
		$response->headers->set('Content-Type', 'video/mp4');
		global $request;
		$response->prepare($request); 
		$response->send();
		exit;
	}
	// Correct the mime type - we force application/octetstream for all files, except images
	// Please do not change this, it is a security precaution
	if (($category != ATTACHMENT_CATEGORY_IMAGE || strpos($attachment['mimetype'], 'image') !== 0))
...
I've forced the Content-Type here to be video, but of course if I get it to work I would set it to audio/video as appropriate.

Re: Setting Content_Type

Posted: Mon Sep 26, 2016 8:25 pm
by kasimi
You missed the last line in this post. :)

Re: Setting Content_Type

Posted: Mon Sep 26, 2016 8:38 pm
by shortmort37
Indeed I did! It reminds me of a joke:

Q: What does a dyslexic agnostic insomniac do?
A: He lies awake all night, and wonders if there really is a dog.

(!)

Hey, it works!! Not only that...




It works on my iPad, which was the whole objective of this little exercise!

Many, many thanks. I will make revision to add mp3 capability as well. This is awesome!

Dan