mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
Add extension to file path on api upload for extension-mapping (#2481)
This commit is contained in:
@@ -17,6 +17,7 @@ use Alchemy\Phrasea\Account\Command\UpdatePasswordCommand;
|
|||||||
use Alchemy\Phrasea\Account\RestrictedStatusExtractor;
|
use Alchemy\Phrasea\Account\RestrictedStatusExtractor;
|
||||||
use Alchemy\Phrasea\Application\Helper\DataboxLoggerAware;
|
use Alchemy\Phrasea\Application\Helper\DataboxLoggerAware;
|
||||||
use Alchemy\Phrasea\Application\Helper\DispatcherAware;
|
use Alchemy\Phrasea\Application\Helper\DispatcherAware;
|
||||||
|
use Alchemy\Phrasea\Application\Helper\FilesystemAware;
|
||||||
use Alchemy\Phrasea\Application\Helper\JsonBodyAware;
|
use Alchemy\Phrasea\Application\Helper\JsonBodyAware;
|
||||||
use Alchemy\Phrasea\Authentication\Exception\RegistrationException;
|
use Alchemy\Phrasea\Authentication\Exception\RegistrationException;
|
||||||
use Alchemy\Phrasea\Authentication\RegistrationService;
|
use Alchemy\Phrasea\Authentication\RegistrationService;
|
||||||
@@ -96,10 +97,12 @@ use Symfony\Component\HttpFoundation\Session\Session;
|
|||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
|
||||||
class V1Controller extends Controller
|
class V1Controller extends Controller
|
||||||
{
|
{
|
||||||
use DataboxLoggerAware;
|
use DataboxLoggerAware;
|
||||||
use DispatcherAware;
|
use DispatcherAware;
|
||||||
|
use FilesystemAware;
|
||||||
use JsonBodyAware;
|
use JsonBodyAware;
|
||||||
|
|
||||||
const OBJECT_TYPE_USER = 'http://api.phraseanet.com/api/objects/user';
|
const OBJECT_TYPE_USER = 'http://api.phraseanet.com/api/objects/user';
|
||||||
@@ -913,7 +916,14 @@ class V1Controller extends Controller
|
|||||||
))->createResponse();
|
))->createResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
$media = $this->app->getMediaFromUri($file->getPathname());
|
// Add file extension
|
||||||
|
$uploadedFilename = $file->getRealPath();
|
||||||
|
|
||||||
|
$renamedFilename = $file->getRealPath() . '.' . pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
$this->getFilesystem()->rename($uploadedFilename, $renamedFilename);
|
||||||
|
|
||||||
|
$media = $this->app->getMediaFromUri($renamedFilename);
|
||||||
|
|
||||||
$Package = new File($this->app, $media, $collection, $file->getClientOriginalName());
|
$Package = new File($this->app, $media, $collection, $file->getClientOriginalName());
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class V1 extends Api implements ControllerProviderInterface, ServiceProviderInte
|
|||||||
return (new V1Controller($app))
|
return (new V1Controller($app))
|
||||||
->setDataboxLoggerLocator($app['phraseanet.logger'])
|
->setDataboxLoggerLocator($app['phraseanet.logger'])
|
||||||
->setDispatcher($app['dispatcher'])
|
->setDispatcher($app['dispatcher'])
|
||||||
|
->setFileSystemLocator(new LazyLocator($app, 'filesystem'))
|
||||||
->setJsonBodyHelper(new LazyLocator($app, 'json.body_helper'));
|
->setJsonBodyHelper(new LazyLocator($app, 'json.body_helper'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user