mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/11912] Integrate mimetype guesser with plupload
PHPBB3-11912
This commit is contained in:
parent
d612041cd1
commit
789d493595
3 changed files with 33 additions and 2 deletions
22
phpBB/config/mimetype_guessers.yml
Normal file
22
phpBB/config/mimetype_guessers.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
services:
|
||||||
|
mimetype.FileinfoMimeTypeGuesser:
|
||||||
|
class: Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser
|
||||||
|
tags:
|
||||||
|
- { name: mimetype.guessers }
|
||||||
|
|
||||||
|
mimetype.FileBinaryMimeTypeGuesser:
|
||||||
|
class: Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser
|
||||||
|
tags:
|
||||||
|
- { name: mimetype.guessers }
|
||||||
|
|
||||||
|
mimetype.guesser_collection:
|
||||||
|
class: phpbb\di\service_collection
|
||||||
|
arguments:
|
||||||
|
- @service_container
|
||||||
|
tags:
|
||||||
|
- { name: service_collection, tag: mimetype.guessers }
|
||||||
|
|
||||||
|
mimetype.guesser:
|
||||||
|
class: phpbb\mimetype\guesser
|
||||||
|
arguments:
|
||||||
|
- @mimetype.guesser_collection
|
|
@ -6,6 +6,7 @@ imports:
|
||||||
- { resource: avatars.yml }
|
- { resource: avatars.yml }
|
||||||
- { resource: feed.yml }
|
- { resource: feed.yml }
|
||||||
- { resource: auth_providers.yml }
|
- { resource: auth_providers.yml }
|
||||||
|
- { resource: mimetype_guessers.yml }
|
||||||
|
|
||||||
services:
|
services:
|
||||||
acl.permissions:
|
acl.permissions:
|
||||||
|
@ -266,6 +267,7 @@ services:
|
||||||
- @request
|
- @request
|
||||||
- @user
|
- @user
|
||||||
- @php_ini
|
- @php_ini
|
||||||
|
- @mimetype.guesser
|
||||||
|
|
||||||
request:
|
request:
|
||||||
class: phpbb\request\request
|
class: phpbb\request\request
|
||||||
|
|
|
@ -49,6 +49,11 @@ class plupload
|
||||||
*/
|
*/
|
||||||
protected $php_ini;
|
protected $php_ini;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \phpbb\mimetype\guesser
|
||||||
|
*/
|
||||||
|
protected $mimetype_guesser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Final destination for uploaded files, i.e. the "files" directory.
|
* Final destination for uploaded files, i.e. the "files" directory.
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -69,16 +74,18 @@ class plupload
|
||||||
* @param \phpbb\request\request_interface $request
|
* @param \phpbb\request\request_interface $request
|
||||||
* @param \phpbb\user $user
|
* @param \phpbb\user $user
|
||||||
* @param \phpbb\php\ini $php_ini
|
* @param \phpbb\php\ini $php_ini
|
||||||
|
* @param \phpbb\mimetype\guesser $mimetype_guesser
|
||||||
*
|
*
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\user $user, \phpbb\php\ini $php_ini)
|
public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\user $user, \phpbb\php\ini $php_ini, \phpbb\mimetype\guesser $mimetype_guesser)
|
||||||
{
|
{
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->php_ini = $php_ini;
|
$this->php_ini = $php_ini;
|
||||||
|
$this->mimetype_guesser = $mimetype_guesser;
|
||||||
|
|
||||||
$this->upload_directory = $this->phpbb_root_path . $this->config['upload_path'];
|
$this->upload_directory = $this->phpbb_root_path . $this->config['upload_path'];
|
||||||
$this->temporary_directory = $this->upload_directory . '/plupload';
|
$this->temporary_directory = $this->upload_directory . '/plupload';
|
||||||
|
@ -128,7 +135,7 @@ class plupload
|
||||||
'tmp_name' => $file_path,
|
'tmp_name' => $file_path,
|
||||||
'name' => $this->request->variable('real_filename', ''),
|
'name' => $this->request->variable('real_filename', ''),
|
||||||
'size' => filesize($file_path),
|
'size' => filesize($file_path),
|
||||||
'type' => $file_info->getMimeType($file_path),
|
'type' => $this->mimetype_guesser->guess($file_path),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue